<html>
<head><meta charset="utf-8"><title>Using `InterpCx` more · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html">Using `InterpCx` more</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="167948609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948609">(Jun 12 2019 at 13:50)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="124288">@oli</span> </p>
<p>This is the discussion thread for <a href="https://github.com/rust-lang/rust/issues/61769" target="_blank" title="https://github.com/rust-lang/rust/issues/61769">#61769</a>.</p>



<a name="167948649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948649">(Jun 12 2019 at 13:51)</a>:</h4>
<p>I'm feeling like we should just close the PR and work on the refactoring to use <code>InterpCx</code> more.</p>



<a name="167948662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948662">(Jun 12 2019 at 13:51)</a>:</h4>
<p>sorry, I should have pushed for this stronger to begin with</p>



<a name="167948665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948665">(Jun 12 2019 at 13:51)</a>:</h4>
<p>What do you think?</p>



<a name="167948675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948675">(Jun 12 2019 at 13:51)</a>:</h4>
<p>No worries! I forgot about that as well.</p>



<a name="167948757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948757">(Jun 12 2019 at 13:52)</a>:</h4>
<p>Either way is fine with me. But if you're willing to work on this, I think in sumtotal it will be less work if you drop the PR, but it will take longer to get somewhere</p>



<a name="167948829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948829">(Jun 12 2019 at 13:53)</a>:</h4>
<p>I'm definitely interested in working on that. Are there specific steps you can think of that need to happen, or is it just one large change?</p>



<a name="167948926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948926">(Jun 12 2019 at 13:54)</a>:</h4>
<p>you can begin with just getting rid of our own <code>OpTy</code> storage and reusing the one from the lowermost frame.</p>



<a name="167948933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948933">(Jun 12 2019 at 13:54)</a>:</h4>
<p>this is zero change in behaviour and just a change in where we store stuff</p>



<a name="167948950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948950">(Jun 12 2019 at 13:54)</a>:</h4>
<p>Ok</p>



<a name="167948965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167948965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167948965">(Jun 12 2019 at 13:54)</a>:</h4>
<p>as an interim step you may even want to stop accessing our storage directly and add setter and getters</p>



<a name="167949002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949002">(Jun 12 2019 at 13:55)</a>:</h4>
<p>then, in the storage-reuse step you can just change the setters and getters without impacting a lot of code</p>



<a name="167949013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949013">(Jun 12 2019 at 13:55)</a>:</h4>
<p>this can be in one PR and just two commits after each other</p>



<a name="167949029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949029">(Jun 12 2019 at 13:55)</a>:</h4>
<p>Ok</p>



<a name="167949051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949051">(Jun 12 2019 at 13:55)</a>:</h4>
<p>"lowermost" you mean the base stack frame or the stack fame currently being evaluated?</p>



<a name="167949119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949119">(Jun 12 2019 at 13:56)</a>:</h4>
<p>the base stack frame, we should only ever have one when inside the const propagator</p>



<a name="167949127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949127">(Jun 12 2019 at 13:56)</a>:</h4>
<p>Ok</p>



<a name="167949130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949130">(Jun 12 2019 at 13:56)</a>:</h4>
<p>you only ever get more stack frames once we start evaluating function calls</p>



<a name="167949143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949143">(Jun 12 2019 at 13:56)</a>:</h4>
<p>and even then they should be finished once control comes back to you</p>



<a name="167949163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949163">(Jun 12 2019 at 13:56)</a>:</h4>
<p>hmm... although in the presence of errors that may not be true</p>



<a name="167949177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949177">(Jun 12 2019 at 13:57)</a>:</h4>
<p>but we'll cross that bridge once we get to function call propagation</p>



<a name="167949194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949194">(Jun 12 2019 at 13:57)</a>:</h4>
<p>We'll probably need to "unwind" the stack back to the callee</p>



<a name="167949201"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949201" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949201">(Jun 12 2019 at 13:57)</a>:</h4>
<p>Sure</p>



<a name="167949214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949214">(Jun 12 2019 at 13:57)</a>:</h4>
<p>ugh, nah, we'll just not prop the call in case of errors :D</p>



<a name="167949233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949233">(Jun 12 2019 at 13:57)</a>:</h4>
<p>miri doesn't even support unwinding yet</p>



<a name="167949246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949246">(Jun 12 2019 at 13:57)</a>:</h4>
<p>Heh, sure :)</p>



<a name="167949341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949341">(Jun 12 2019 at 13:58)</a>:</h4>
<p>Then to actually use <code>InterpCx</code>, I guess I need to set up that frame?</p>



<a name="167949354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949354">(Jun 12 2019 at 13:58)</a>:</h4>
<p>Or do we already have one?</p>



<a name="167949559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949559">(Jun 12 2019 at 14:00)</a>:</h4>
<p>we have one</p>



<a name="167949600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949600">(Jun 12 2019 at 14:01)</a>:</h4>
<p>but we specifically don't create locals iirc</p>



<a name="167949645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949645">(Jun 12 2019 at 14:01)</a>:</h4>
<p>Ok. I can dig into that more tonight</p>



<a name="167949803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167949803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167949803">(Jun 12 2019 at 14:03)</a>:</h4>
<p>basically we're calling <a href="https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/const_eval.rs#L46" target="_blank" title="https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/const_eval.rs#L46">https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/const_eval.rs#L46</a> which in turn creates an empty <code>InterpCx</code>: <a href="https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/interpret/eval_context.rs#L213" target="_blank" title="https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/interpret/eval_context.rs#L213">https://github.com/rust-lang/rust/blob/1cbd8a4d686d1411105f26cddf876c5994e69593/src/librustc_mir/interpret/eval_context.rs#L213</a></p>



<a name="167950012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950012">(Jun 12 2019 at 14:05)</a>:</h4>
<p>That's helpful, thanks!</p>



<a name="167950027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950027">(Jun 12 2019 at 14:05)</a>:</h4>
<p>I think you should be able to just call <a href="https://github.com/rust-lang/rust/blob/3d7a1c9dc81b0da3140fe008a2276d6f2c266f10/src/librustc_mir/interpret/eval_context.rs#L474" target="_blank" title="https://github.com/rust-lang/rust/blob/3d7a1c9dc81b0da3140fe008a2276d6f2c266f10/src/librustc_mir/interpret/eval_context.rs#L474"><code>push_stack_frame</code></a> after the call to <code>mk_eval_cx</code></p>



<a name="167950033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950033">(Jun 12 2019 at 14:05)</a>:</h4>
<p>all information should be available</p>



<a name="167950048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950048">(Jun 12 2019 at 14:05)</a>:</h4>
<p>although not so sure about the <code>mir::Body</code></p>



<a name="167950053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950053">(Jun 12 2019 at 14:05)</a>:</h4>
<p>maybe just feed in an empty <code>mir::Body</code></p>



<a name="167950140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950140">(Jun 12 2019 at 14:06)</a>:</h4>
<p>oh, I tried that before, hmm...</p>



<a name="167950161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950161">(Jun 12 2019 at 14:06)</a>:</h4>
<p>Don't I need the locals though? <a href="https://github.com/rust-lang/rust/blob/3d7a1c9dc81b0da3140fe008a2276d6f2c266f10/src/librustc_mir/interpret/eval_context.rs#L504" target="_blank" title="https://github.com/rust-lang/rust/blob/3d7a1c9dc81b0da3140fe008a2276d6f2c266f10/src/librustc_mir/interpret/eval_context.rs#L504">https://github.com/rust-lang/rust/blob/3d7a1c9dc81b0da3140fe008a2276d6f2c266f10/src/librustc_mir/interpret/eval_context.rs#L504</a></p>



<a name="167950169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950169">(Jun 12 2019 at 14:06)</a>:</h4>
<p>ah you are already ripping out the <code>LocalDecls</code> from the <code>mir::Body</code></p>



<a name="167950187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950187">(Jun 12 2019 at 14:07)</a>:</h4>
<p>Oh, right</p>



<a name="167950199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950199">(Jun 12 2019 at 14:07)</a>:</h4>
<p>yea <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> you're right, we need them, so no empty <code>mir::Body</code></p>



<a name="167950224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950224">(Jun 12 2019 at 14:07)</a>:</h4>
<p>but maybe we can create a mostly dummy <code>mir::Body</code> with just the ripped out info</p>



<a name="167950287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950287">(Jun 12 2019 at 14:08)</a>:</h4>
<p>instead of storing the info in the const propagator, we store it in the <code>mir::Body</code> that we give the first stack frame</p>



<a name="167950306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950306">(Jun 12 2019 at 14:08)</a>:</h4>
<p>OK, I realize it wasn't as straight forward as I thought at the beginning</p>



<a name="167950316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950316">(Jun 12 2019 at 14:08)</a>:</h4>
<p>once upon a time we had a dummy stack frame</p>



<a name="167950322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950322">(Jun 12 2019 at 14:08)</a>:</h4>
<p>Still doesn't sound that bad though :)</p>



<a name="167950335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950335">(Jun 12 2019 at 14:08)</a>:</h4>
<p>yea</p>



<a name="167950390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950390">(Jun 12 2019 at 14:09)</a>:</h4>
<p>I'll try to work on this a bit tonight and report back if I have any questions</p>



<a name="167950404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950404">(Jun 12 2019 at 14:09)</a>:</h4>
<p>awesome</p>



<a name="167950417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/167950417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#167950417">(Jun 12 2019 at 14:09)</a>:</h4>
<p>ttyl</p>



<a name="168123280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168123280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168123280">(Jun 14 2019 at 10:17)</a>:</h4>
<p>So I've started working on this and I've got some in progress changes but I'm running into <code>InterpretCx::push_stack_frame()</code> needing a <code>&amp;'mir Body</code> while <code>ConstPropagator::visit_body()</code> also needs a <code>&amp;mir Body</code> at the same time. See <a href="https://github.com/wesleywiser/rust/blob/79d76d8b7d8074ce156694d93326ccf154e95d84/src/librustc_mir/transform/const_prop.rs#L79-L86" target="_blank" title="https://github.com/wesleywiser/rust/blob/79d76d8b7d8074ce156694d93326ccf154e95d84/src/librustc_mir/transform/const_prop.rs#L79-L86">here</a></p>



<a name="168123282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168123282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168123282">(Jun 14 2019 at 10:17)</a>:</h4>
<p>Any ideas?</p>



<a name="168125194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168125194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168125194">(Jun 14 2019 at 10:52)</a>:</h4>
<p>yes, create a dummy <code>mir::Body</code> and put the things you stole from the other <code>mir::Body</code> in there</p>



<a name="168125202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168125202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168125202">(Jun 14 2019 at 10:53)</a>:</h4>
<p>not sure what creating a dummy <code>mir::Body</code> entails, but you should be able to use <code>Default::default</code> for many things</p>



<a name="168388677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168388677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168388677">(Jun 18 2019 at 10:47)</a>:</h4>
<p>So in order to <code>push_stack_frame()</code>, I need an <code>Instance</code>. As far as I can tell, there's no <code>SubstsRef</code> for the <code>Body</code> we're operating on. I tried this <a href="https://github.com/rust-lang/rust/commit/faf730b0c9725b44cd54292e5be1b8c5e056bff0#diff-9e103702275cbef342c2decd3395bf3bR176" target="_blank" title="https://github.com/rust-lang/rust/commit/faf730b0c9725b44cd54292e5be1b8c5e056bff0#diff-9e103702275cbef342c2decd3395bf3bR176">https://github.com/rust-lang/rust/commit/faf730b0c9725b44cd54292e5be1b8c5e056bff0#diff-9e103702275cbef342c2decd3395bf3bR176</a> but that causes normalization errors because there are unresolved generics. Is <code>identity_for_item()</code> the right thing to use here or is there something else I should be using to get a <code>SubstsRef</code>?</p>



<a name="168389048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168389048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168389048">(Jun 18 2019 at 10:54)</a>:</h4>
<p>hmm... I wonder how much we really need the <code>Instance</code> in each stack frame</p>



<a name="168389064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168389064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168389064">(Jun 18 2019 at 10:54)</a>:</h4>
<p>mostly for substs I presume, but maybe we sometimes need the <code>DefId</code>, too?</p>



<a name="168389076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168389076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168389076">(Jun 18 2019 at 10:54)</a>:</h4>
<p>I think for now you can add a <code>//HACK</code> comment and just create the instance manually instead of via <code>new</code></p>



<a name="168389318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168389318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168389318">(Jun 18 2019 at 10:59)</a>:</h4>
<p>Should I just pass in an empty <code>SubstsRef</code>?</p>



<a name="168390021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168390021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168390021">(Jun 18 2019 at 11:11)</a>:</h4>
<p>Oh, fyi the assert is not coming from <code>Instance::new()</code>, it's later when we try to get the layout of a local that isn't fully normalized.</p>



<a name="168390084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168390084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168390084">(Jun 18 2019 at 11:12)</a>:</h4>
<p>For example:</p>
<div class="codehilite"><pre><span></span>error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:43: could not fully normalize `&lt;T as iter::traits::collect::IntoIterator&gt;::IntoIter`

thread &#39;rustc&#39; panicked at &#39;Box&lt;Any&gt;&#39;, src/librustc_errors/lib.rs:643:9
stack backtrace:
   0: std::sys_common::backtrace::print
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: rustc::util::common::panic_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::bug
   7: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   8: rustc::ty::context::tls::with_opt::{{closure}}
   9: rustc::ty::context::tls::with_context_opt
  10: rustc::ty::context::tls::with_opt
  11: rustc::util::bug::opt_span_bug_fmt
  12: rustc::util::bug::bug_fmt
  13: rustc::ty::context::GlobalCtxt::enter_local
  14: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions
  15: rustc::ty::query::__query_compute::normalize_ty_after_erasing_regions
  16: rustc::ty::query::&lt;impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::normalize_ty_after_erasing_regions&gt;::compute
  17: rustc::dep_graph::graph::DepGraph::with_task_impl
  18: rustc::ty::query::plumbing::&lt;impl rustc::ty::context::TyCtxt&gt;::get_query
  19: &lt;rustc::traits::query::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc::ty::fold::TypeFolder&gt;::fold_ty
  20: rustc::traits::query::normalize_erasing_regions::&lt;impl rustc::ty::context::TyCtxt&gt;::normalize_erasing_regions
  21: rustc_mir::interpret::eval_context::InterpretCx&lt;M&gt;::layout_of_local
  22: rustc_mir::interpret::operand::&lt;impl rustc_mir::interpret::eval_context::InterpretCx&lt;M&gt;&gt;::access_local
  23: rustc_mir::transform::const_prop::ConstPropagator::get_const
  24: rustc_mir::transform::const_prop::ConstPropagator::eval_place::{{closure}}
  25: rustc::mir::Place::iterate2
  26: &lt;rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor&gt;::visit_statement
  27: rustc::mir::visit::MutVisitor::visit_body
  28: &lt;rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass&gt;::run_pass
</pre></div>



<a name="168390839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168390839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168390839">(Jun 18 2019 at 11:25)</a>:</h4>
<p>oh</p>



<a name="168390845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168390845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168390845">(Jun 18 2019 at 11:25)</a>:</h4>
<p>I thought it was during creation</p>



<a name="168390940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168390940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168390940">(Jun 18 2019 at 11:26)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span>  maybe we should bail out during <code>layout_of_local</code> if the type passed to it <code>needs_substs()</code> (bail out with <code>err!(TooGeneric)</code></p>



<a name="168391166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168391166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168391166">(Jun 18 2019 at 11:30)</a>:</h4>
<p>oh, no it's not quite that easy</p>



<a name="168391172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168391172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168391172">(Jun 18 2019 at 11:30)</a>:</h4>
<p>it should be in <code>monomorphize_with_substs</code></p>



<a name="168391203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168391203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168391203">(Jun 18 2019 at 11:31)</a>:</h4>
<p>basically if <code>substituted.needs_subst()</code></p>



<a name="168391206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168391206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168391206">(Jun 18 2019 at 11:31)</a>:</h4>
<p>before doing the normalization run</p>



<a name="168391228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168391228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168391228">(Jun 18 2019 at 11:31)</a>:</h4>
<p>if substitution didn't make it monomorphic, bail out</p>



<a name="168399203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399203">(Jun 18 2019 at 13:14)</a>:</h4>
<p>Ok, that seems to work although most of the <code>const-prop</code> tests are broken now <span aria-label="sweat" class="emoji emoji-1f613" role="img" title="sweat">:sweat:</span> </p>
<p>I'll investigate more tonight.</p>



<a name="168399550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399550">(Jun 18 2019 at 13:19)</a>:</h4>
<p>you only moved the storage from the custom <code>OpTy</code> storage to the first frame's storage, right?</p>



<a name="168399580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399580">(Jun 18 2019 at 13:19)</a>:</h4>
<p>no const prop logic has been changed to make (more) use of the <code>InterpCx</code> methods</p>



<a name="168399831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399831">(Jun 18 2019 at 13:22)</a>:</h4>
<p>Sort of. I'm not 100% sure of my changes</p>



<a name="168399859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399859">(Jun 18 2019 at 13:23)</a>:</h4>
<p>This assert was failing <a href="https://github.com/rust-lang/rust/blob/faf730b0c9725b44cd54292e5be1b8c5e056bff0/src/librustc_mir/transform/const_prop.rs#L773" target="_blank" title="https://github.com/rust-lang/rust/blob/faf730b0c9725b44cd54292e5be1b8c5e056bff0/src/librustc_mir/transform/const_prop.rs#L773">https://github.com/rust-lang/rust/blob/faf730b0c9725b44cd54292e5be1b8c5e056bff0/src/librustc_mir/transform/const_prop.rs#L773</a></p>



<a name="168399891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399891">(Jun 18 2019 at 13:23)</a>:</h4>
<p>Because <code>self.get_const()</code> was already returning the right const value before we'd even set it.</p>



<a name="168399977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168399977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168399977">(Jun 18 2019 at 13:24)</a>:</h4>
<p>Which is not what I'd expected at all.</p>



<a name="168400335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400335">(Jun 18 2019 at 13:28)</a>:</h4>
<p>hmm... that may be due to <code>push_stack_frame</code> initializing all locals that have neither <code>StorageLive</code> nor <code>StorageDead</code> calls</p>



<a name="168400402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400402">(Jun 18 2019 at 13:29)</a>:</h4>
<p>Interesting...</p>



<a name="168400406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400406">(Jun 18 2019 at 13:29)</a>:</h4>
<p>That's helpful</p>



<a name="168400432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400432">(Jun 18 2019 at 13:29)</a>:</h4>
<p>There's a number of places that use <code>self.ecx</code> to perform a more complex operation. Perhaps some of those are also mutating locals in the frame?</p>



<a name="168400604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400604">(Jun 18 2019 at 13:31)</a>:</h4>
<p>they shouldn't, I mean they would have failed before, too</p>



<a name="168400664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400664">(Jun 18 2019 at 13:31)</a>:</h4>
<p>maybe just start by checking that after the <code>push_stack_frame</code> all locals are <code>Uninitialized</code>. If they aren't then we know the culprit</p>



<a name="168400715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400715">(Jun 18 2019 at 13:32)</a>:</h4>
<p>if they are, maybe some of the trace logs shed some light</p>



<a name="168400914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400914">(Jun 18 2019 at 13:34)</a>:</h4>
<p>That's a good idea</p>



<a name="168400925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168400925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168400925">(Jun 18 2019 at 13:34)</a>:</h4>
<p>I'll do that tonight</p>



<a name="168924288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168924288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168924288">(Jun 25 2019 at 10:00)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> Ok, so I'm trying to use <code>InterpretCx</code> more and I have a pretty simple change:</p>
<div class="codehilite"><pre><span></span><span class="gh">diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs</span>
<span class="gh">index b5dbaaa2327..a71989f70f1 100644</span>
<span class="gd">--- a/src/librustc_mir/transform/const_prop.rs</span>
<span class="gi">+++ b/src/librustc_mir/transform/const_prop.rs</span>
<span class="gu">@@ -452,8 +452,10 @@ impl&lt;&#39;mir, &#39;tcx&gt; ConstPropagator&lt;&#39;mir, &#39;tcx&gt; {</span>
                 self.eval_operand(op, source_info)
             },
             Rvalue::Ref(_, _, ref place) =&gt; {
<span class="gd">-                let src = self.eval_place(place, source_info)?;</span>
<span class="gd">-                let mplace = src.try_as_mplace().ok()?;</span>
<span class="gi">+                let mplace = self.use_ecx(source_info, |this| {</span>
<span class="gi">+                    let place = this.ecx.eval_place(place)?;</span>
<span class="gi">+                    this.ecx.force_allocation(place)</span>
<span class="gi">+                })?;</span>
                 Some(ImmTy::from_scalar(mplace.ptr.into(), place_layout).into())
             },
             Rvalue::Repeat(..) |
</pre></div>


<p>However, I'm getting an error when bootstrapping:</p>
<div class="codehilite"><pre><span></span>error[E0391]: cycle detected when processing `f32::&lt;impl at src/libcore/num/f32.rs:149:1: 464:2&gt;::is_normal`
   --&gt; src/libcore/num/f32.rs:246:28
    |
246 |         self.classify() == FpCategory::Normal
    |                            ^^^^^^^^^^^^^^^^^^
    |
note: ...which requires const-evaluating `f32::&lt;impl at src/libcore/num/f32.rs:149:1: 464:2&gt;::is_normal`...
   --&gt; src/libcore/num/f32.rs:245:5
    |
245 |     pub fn is_normal(self) -&gt; bool {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: ...which again requires processing `f32::&lt;impl at src/libcore/num/f32.rs:149:1: 464:2&gt;::is_normal`, completing the cycle

error: aborting due to previous error
</pre></div>


<p>which I think is happening because <code>InterpretCx::eval_place</code> calls <code>eval_static_to_mplace</code> which calls <code>const_eval_raw</code> which tries to load the MIR for the function that's already being processed which causes the cycle. Does that sound correct to you?</p>



<a name="168927970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168927970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168927970">(Jun 25 2019 at 11:10)</a>:</h4>
<p>Oh, because it's a promoted of the current function</p>



<a name="168928090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168928090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168928090">(Jun 25 2019 at 11:12)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span>  you could modify <code>load_mir</code> to not hit <code>tcx.optimized_mir</code>if it's a promoted and the <code>DefId</code> of is the same as any frame's <code>Instance</code>'s <code>DefId</code> and just fetch the <code>mir::Body</code> of the promoted from there</p>



<a name="168928112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168928112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168928112">(Jun 25 2019 at 11:13)</a>:</h4>
<p>that means you'll also have to steal the <code>promoted</code>field</p>



<a name="168932418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168932418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168932418">(Jun 25 2019 at 12:17)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> Hmm... that doesn't seem to work because in <code>InterpretCx::load_mir()</code>, our <code>self</code> is not the same <code>InterpretCx</code> that we are using for const prop. There's a new one created here <a href="https://github.com/rust-lang/rust/blob/10deeae3263301f1d337721ed55c14637b70c3c7/src/librustc_mir/const_eval.rs#L636" target="_blank" title="https://github.com/rust-lang/rust/blob/10deeae3263301f1d337721ed55c14637b70c3c7/src/librustc_mir/const_eval.rs#L636">https://github.com/rust-lang/rust/blob/10deeae3263301f1d337721ed55c14637b70c3c7/src/librustc_mir/const_eval.rs#L636</a></p>



<a name="168936379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168936379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168936379">(Jun 25 2019 at 13:08)</a>:</h4>
<p>oh no XD</p>



<a name="168936388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168936388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168936388">(Jun 25 2019 at 13:08)</a>:</h4>
<p>hmm... how did this work before?</p>



<a name="168936393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168936393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168936393">(Jun 25 2019 at 13:08)</a>:</h4>
<p>oh we had a special <code>eval_place</code> in the const propagator</p>



<a name="168936435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168936435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168936435">(Jun 25 2019 at 13:09)</a>:</h4>
<p>hmm... sorry I gotta run, not sure what to do there for promoteds</p>



<a name="168936585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/168936585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#168936585">(Jun 25 2019 at 13:11)</a>:</h4>
<p>Ok, see ya <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="169022515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169022515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169022515">(Jun 26 2019 at 12:07)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>  I have some changes I'm playing around with that I think will make this work but I'm not sure if this is the right direction</p>



<a name="169022518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169022518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169022518">(Jun 26 2019 at 12:07)</a>:</h4>
<p>Or if you'll like them <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="169022574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169022574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169022574">(Jun 26 2019 at 12:08)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:ecx_refactoring?expand=1" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:ecx_refactoring?expand=1">https://github.com/rust-lang/rust/compare/master...wesleywiser:ecx_refactoring?expand=1</a></p>



<a name="169027613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169027613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169027613">(Jun 26 2019 at 13:12)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> heh, right direction, but removing the <code>const_eval_raw</code> unconditionally is not an option</p>



<a name="169027714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169027714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169027714">(Jun 26 2019 at 13:13)</a>:</h4>
<p>are you planning on creating a <code>ConstProp</code> machine?</p>



<a name="169027723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169027723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169027723">(Jun 26 2019 at 13:13)</a>:</h4>
<p>or what's the <code>intern_alloc</code> change for?</p>



<a name="169027780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169027780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169027780">(Jun 26 2019 at 13:14)</a>:</h4>
<p>if so, you could create an <code>eval_promoted</code> machine hook</p>



<a name="169029210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029210">(Jun 26 2019 at 13:30)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> the <code>intern_alloc</code> change is because <code>InterpretCx::eval_static_to_mplace()</code> is generic over the <code>Machine</code> but <code>eval_body_using_ecx()</code> was hardcoded to <code>CompileTimeEvalContext</code>. So in order to call it from <code>eval_static_to_mplace()</code>, I had to make it generic as well.</p>



<a name="169029298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029298">(Jun 26 2019 at 13:30)</a>:</h4>
<p>ah XD</p>



<a name="169029300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029300">(Jun 26 2019 at 13:30)</a>:</h4>
<p><code>eval_promoted</code> sounds like a better name for the trait method to me</p>



<a name="169029344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029344">(Jun 26 2019 at 13:30)</a>:</h4>
<p>and there I was hoping for a const prop machine :P</p>



<a name="169029412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029412">(Jun 26 2019 at 13:31)</a>:</h4>
<p>so anyway, I'm not quite sure how to do this best</p>



<a name="169029450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029450">(Jun 26 2019 at 13:31)</a>:</h4>
<p>heh maybe that's the right answer but I don't think I have a good enough grasp of the miri architecture to do that correctly</p>



<a name="169029452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029452">(Jun 26 2019 at 13:31)</a>:</h4>
<p>We don't want to duplicate computing promoteds</p>



<a name="169029513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029513">(Jun 26 2019 at 13:32)</a>:</h4>
<p>Duplicate between what?</p>



<a name="169029537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029537">(Jun 26 2019 at 13:32)</a>:</h4>
<p>Oh, the other code in <code>ConstProp</code>?</p>



<a name="169029566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029566">(Jun 26 2019 at 13:32)</a>:</h4>
<p>well, const prop computes the promoted, and then later const eval or codegen compute it again</p>



<a name="169029574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029574">(Jun 26 2019 at 13:32)</a>:</h4>
<p>because it wasn't cached this time around</p>



<a name="169029576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029576">(Jun 26 2019 at 13:32)</a>:</h4>
<p>oh</p>



<a name="169029590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029590">(Jun 26 2019 at 13:32)</a>:</h4>
<p>we are <em>already</em> doing that</p>



<a name="169029598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029598">(Jun 26 2019 at 13:33)</a>:</h4>
<p>The code in <code>ConstProp</code> will go away once this works</p>



<a name="169029630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029630">(Jun 26 2019 at 13:33)</a>:</h4>
<p>(I think)</p>



<a name="169029656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029656">(Jun 26 2019 at 13:33)</a>:</h4>
<p>no I mean, the <code>ConstProp</code> code is ungreat right now</p>



<a name="169029681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029681">(Jun 26 2019 at 13:33)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> very true</p>



<a name="169029688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029688">(Jun 26 2019 at 13:33)</a>:</h4>
<p>you didn't make it worse by moving to using <code>InterpCx</code></p>



<a name="169029754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029754">(Jun 26 2019 at 13:34)</a>:</h4>
<p>either implementation computed (or tried to compute) the promoted</p>



<a name="169029768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029768">(Jun 26 2019 at 13:34)</a>:</h4>
<p>and then later we compute it again in <code>monomorphize::collect</code></p>



<a name="169029800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029800">(Jun 26 2019 at 13:34)</a>:</h4>
<p>so if we have a complex generic promoted, that can be a lot of computation time wasted</p>



<a name="169029913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029913">(Jun 26 2019 at 13:35)</a>:</h4>
<p>Should we make a query for computing promoted values so they get cached?</p>



<a name="169029999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169029999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169029999">(Jun 26 2019 at 13:36)</a>:</h4>
<p>lol, like use the <code>mir::Body</code> of the promoted as the query key?</p>



<a name="169030064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030064">(Jun 26 2019 at 13:37)</a>:</h4>
<p>While that would cache it, the hashing may be very expensive</p>



<a name="169030089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030089">(Jun 26 2019 at 13:37)</a>:</h4>
<p>Couldn't we use the index of the promoted in it's parent's <code>Body.promoted</code>?</p>



<a name="169030148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030148">(Jun 26 2019 at 13:38)</a>:</h4>
<p>but that would then cause the cycle again</p>



<a name="169030156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030156">(Jun 26 2019 at 13:38)</a>:</h4>
<p>Ah right</p>



<a name="169030178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030178">(Jun 26 2019 at 13:38)</a>:</h4>
<p>Why are promoted stored this way?</p>



<a name="169030196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030196">(Jun 26 2019 at 13:38)</a>:</h4>
<p>because it seemed easy</p>



<a name="169030200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030200">(Jun 26 2019 at 13:38)</a>:</h4>
<p>Ah</p>



<a name="169030213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030213">(Jun 26 2019 at 13:39)</a>:</h4>
<p>like the alternative is to introduce generic <code>static</code> items in the query system</p>



<a name="169030236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030236">(Jun 26 2019 at 13:39)</a>:</h4>
<p>and generate <code>DefId</code>s for them, which... seems dangerous</p>



<a name="169030272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030272">(Jun 26 2019 at 13:39)</a>:</h4>
<p>Ok</p>



<a name="169030361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030361">(Jun 26 2019 at 13:40)</a>:</h4>
<p>Well it sounds like this isn't making anything <em>worse</em></p>



<a name="169030374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030374">(Jun 26 2019 at 13:40)</a>:</h4>
<p>I have a moderately stupid idea</p>



<a name="169030381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030381">(Jun 26 2019 at 13:40)</a>:</h4>
<p>It's just not necessarily better</p>



<a name="169030402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030402">(Jun 26 2019 at 13:40)</a>:</h4>
<p>It's probably not that stupid <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="169030661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030661">(Jun 26 2019 at 13:43)</a>:</h4>
<p>we create a <code>const_qualif</code> query whose return type is <code>(Steal&lt;mir::Body&gt;, &amp;'tcx [mir::Body])</code> and that query first runs all the pre-const-qualif <code>MirPass</code>es, then does <code>const_qualif</code> and returns the <code>mir::Body</code> in a stealable way and the promoteds just plain</p>



<a name="169030727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030727">(Jun 26 2019 at 13:44)</a>:</h4>
<p>then the <code>optimized_mir</code> query first runs <code>const_qualif</code>, steals the <code>MIR</code> and runs the rest of the <code>MirPass</code>es</p>



<a name="169030880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030880">(Jun 26 2019 at 13:45)</a>:</h4>
<p><code>CopyProp</code> then doesn't need to change <code>InterpCx</code> like you did, but can just invoke the existing code. <code>const_eval</code> will use the <code>const_qualif</code> query when it needs <code>promoted</code> <code>mir::Body</code>s</p>



<a name="169030912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169030912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169030912">(Jun 26 2019 at 13:45)</a>:</h4>
<p>so instead of having a <code>promoted</code> field, one obtains the <code>promoted</code> <code>mir::Body</code> by using the <code>const_qualif</code> query</p>



<a name="169031006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031006">(Jun 26 2019 at 13:46)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119009">@eddyb</span> I'm planning weird things with promoteds again, sanity check please</p>



<a name="169031152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031152">(Jun 26 2019 at 13:47)</a>:</h4>
<p>And that will let us remove the duplication?</p>



<a name="169031161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031161">(Jun 26 2019 at 13:47)</a>:</h4>
<p>Not sure I'm totally following tbh</p>



<a name="169031231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031231">(Jun 26 2019 at 13:48)</a>:</h4>
<p>(Still drinking my morning coffee)</p>



<a name="169031317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031317">(Jun 26 2019 at 13:49)</a>:</h4>
<p>yes, because calling <code>const_eval_raw</code> is a cached query and thus deduplicates</p>



<a name="169031373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031373">(Jun 26 2019 at 13:49)</a>:</h4>
<p>Oh oh ok</p>



<a name="169031402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031402">(Jun 26 2019 at 13:49)</a>:</h4>
<p>Sorry, I thought you mean duplicated code</p>



<a name="169031417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031417">(Jun 26 2019 at 13:49)</a>:</h4>
<p>Not, re evaluating the same promoteds</p>



<a name="169031419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031419">(Jun 26 2019 at 13:49)</a>:</h4>
<p>nah, that would have been gone via your PRs scheme, too</p>



<a name="169031420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031420">(Jun 26 2019 at 13:49)</a>:</h4>
<p>Got it</p>



<a name="169031539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031539">(Jun 26 2019 at 13:50)</a>:</h4>
<p>but let's wait for eddyb's insights</p>



<a name="169031553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031553">(Jun 26 2019 at 13:50)</a>:</h4>
<p>So the other wrinkle I've found (besides some ICEs I'm still trying to fix) is that <code>eval_static_to_mplace()</code> will also eval statics</p>



<a name="169031571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031571">(Jun 26 2019 at 13:50)</a>:</h4>
<p>hmm...</p>



<a name="169031573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031573">(Jun 26 2019 at 13:50)</a>:</h4>
<p>Which we decided the other week we definitely don't want to do in const prop</p>



<a name="169031592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031592">(Jun 26 2019 at 13:51)</a>:</h4>
<p>we also don't want this to happen inside constants</p>



<a name="169031601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031601">(Jun 26 2019 at 13:51)</a>:</h4>
<p>Do you have a prefered way to handle that?</p>



<a name="169031612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031612">(Jun 26 2019 at 13:51)</a>:</h4>
<p>currently that is prevented via <code>const_qualif</code></p>



<a name="169031629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031629">(Jun 26 2019 at 13:51)</a>:</h4>
<p>but I'd like <code>InterpCx</code> to prevent that by itself</p>



<a name="169031659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031659">(Jun 26 2019 at 13:51)</a>:</h4>
<p>I was just going to add a flag or function to the <code>Machine</code> to see if we should do that. But I haven't thought about it very much.</p>



<a name="169031809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031809">(Jun 26 2019 at 13:52)</a>:</h4>
<p>I think you don't need to do anything fancy, basically the only way you could ever want to eval a static is if there is only one stack frame and that stack frame's <code>instance</code> is also a <code>static</code> item</p>



<a name="169031823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031823">(Jun 26 2019 at 13:52)</a>:</h4>
<p>my reasoning is as follows:</p>



<a name="169031864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031864">(Jun 26 2019 at 13:53)</a>:</h4>
<p>if you have a single stack frame and it's not a static, it must be a constant or promoted, and those should not refer to a <code>static</code></p>



<a name="169031899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031899">(Jun 26 2019 at 13:53)</a>:</h4>
<p>if you have more stack frames, you are evaluating <code>const fn</code>s, and those should also not be evaluating any <code>static</code>s</p>



<a name="169031976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031976">(Jun 26 2019 at 13:54)</a>:</h4>
<p>Put another way, if the single stack frame is <code>static</code> then whatever requested const evaluation is obviously fine with eval-ing statics?</p>



<a name="169031983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031983">(Jun 26 2019 at 13:54)</a>:</h4>
<p>yes</p>



<a name="169031987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031987">(Jun 26 2019 at 13:54)</a>:</h4>
<p>Yeah</p>



<a name="169031990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031990">(Jun 26 2019 at 13:54)</a>:</h4>
<p>and you can even ICE for non-promoteds</p>



<a name="169031991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169031991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169031991">(Jun 26 2019 at 13:54)</a>:</h4>
<p>That makes sense</p>



<a name="169032016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032016">(Jun 26 2019 at 13:54)</a>:</h4>
<p>Ok, that's really helpful</p>



<a name="169032025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032025">(Jun 26 2019 at 13:54)</a>:</h4>
<p>Thanks!</p>



<a name="169032026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032026">(Jun 26 2019 at 13:55)</a>:</h4>
<p>promoteds need to error out some way so that <code>ConstProp</code> can handle it</p>



<a name="169032082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032082">(Jun 26 2019 at 13:55)</a>:</h4>
<p>Probably just adding a new error variant to the InterpretError enum</p>



<a name="169032107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032107">(Jun 26 2019 at 13:55)</a>:</h4>
<p>oh actually.... all of these can ICE</p>



<a name="169032214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032214">(Jun 26 2019 at 13:56)</a>:</h4>
<p>yea just <code>assert!(self.frames.len() == 1 &amp;&amp; self.tcx.is_static(self.frame().instance.def_id()));</code> :D</p>



<a name="169032231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032231">(Jun 26 2019 at 13:56)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="169032248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032248">(Jun 26 2019 at 13:56)</a>:</h4>
<p>or maybe <code>delay_span_bug</code> if that makes anything unhappy</p>



<a name="169032267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032267">(Jun 26 2019 at 13:57)</a>:</h4>
<p>Ok</p>



<a name="169032327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032327">(Jun 26 2019 at 13:57)</a>:</h4>
<p>you want to do what?!</p>



<a name="169032348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032348">(Jun 26 2019 at 13:57)</a>:</h4>
<p>sorry, just saw the ping :P</p>



<a name="169032353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032353">(Jun 26 2019 at 13:57)</a>:</h4>
<p>heheh</p>



<a name="169032405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032405">(Jun 26 2019 at 13:58)</a>:</h4>
<p>there's text above the ping, or do you want another summary?</p>



<a name="169032421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032421">(Jun 26 2019 at 13:58)</a>:</h4>
<p>ah, above, not below?</p>



<a name="169032457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032457">(Jun 26 2019 at 13:58)</a>:</h4>
<p>yes</p>



<a name="169032474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032474">(Jun 26 2019 at 13:58)</a>:</h4>
<p>ah wait I did read above</p>



<a name="169032493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032493">(Jun 26 2019 at 13:59)</a>:</h4>
<blockquote>
<p>so instead of having a <code>promoted</code> field, one obtains the <code>promoted</code> <code>mir::Body</code> by using the <code>const_qualif</code> query</p>
</blockquote>



<a name="169032501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032501">(Jun 26 2019 at 13:59)</a>:</h4>
<p>this is very scary?</p>



<a name="169032507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032507">(Jun 26 2019 at 13:59)</a>:</h4>
<p>yes</p>



<a name="169032548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032548">(Jun 26 2019 at 13:59)</a>:</h4>
<p>but less annoying than having <code>MirPass</code>es try to const eval promoteds</p>



<a name="169032556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032556">(Jun 26 2019 at 13:59)</a>:</h4>
<p>(it's not a question, idk why I put a "?" at the end)</p>



<a name="169032637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032637">(Jun 26 2019 at 14:00)</a>:</h4>
<p>I see no way to cache promoted const evals during <code>MirPass</code>es</p>



<a name="169032649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032649">(Jun 26 2019 at 14:00)</a>:</h4>
<p>other than the proposed way</p>



<a name="169032663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032663">(Jun 26 2019 at 14:00)</a>:</h4>
<p>you could have a <code>promoted_mir</code> query that uses <code>const_qualif</code> and then does what you said</p>



<a name="169032704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032704">(Jun 26 2019 at 14:00)</a>:</h4>
<p>but that would need to modify the main <code>mir::Body</code>, too</p>



<a name="169032716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032716">(Jun 26 2019 at 14:00)</a>:</h4>
<p>so we need a query that returns both, I think?</p>



<a name="169032753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032753">(Jun 26 2019 at 14:01)</a>:</h4>
<p>yeah, sure, just, don't stick it in <code>const_qualif</code> literally</p>



<a name="169032761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032761">(Jun 26 2019 at 14:01)</a>:</h4>
<p>oh right</p>



<a name="169032777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032777">(Jun 26 2019 at 14:01)</a>:</h4>
<p>yea that was a strawman name</p>



<a name="169032944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032944">(Jun 26 2019 at 14:02)</a>:</h4>
<p>okay so the problem is that <code>promoted</code>s being inside the parent <code>Mir</code> is a  hack and you want to keep them separate so you can query the promoteds at any time?</p>



<a name="169032957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032957">(Jun 26 2019 at 14:03)</a>:</h4>
<p>yes</p>



<a name="169032984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169032984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169032984">(Jun 26 2019 at 14:03)</a>:</h4>
<p>how do you plan to handle this cross-crate?</p>



<a name="169033131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033131">(Jun 26 2019 at 14:04)</a>:</h4>
<p>place the <code>promoted_mir</code> query in metadata I guess?</p>



<a name="169033193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033193">(Jun 26 2019 at 14:04)</a>:</h4>
<p>at least the ones that are still reachable</p>



<a name="169033220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033220">(Jun 26 2019 at 14:05)</a>:</h4>
<p>yeah but... the local-crate version needs to return more things :P</p>



<a name="169033238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033238">(Jun 26 2019 at 14:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> might care about this discussion, although he's busy</p>



<a name="169033362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033362">(Jun 26 2019 at 14:06)</a>:</h4>
<p>how is that different from the <code>optimized_mir</code> query?</p>



<a name="169033401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033401">(Jun 26 2019 at 14:06)</a>:</h4>
<p>hmm?</p>



<a name="169033454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033454">(Jun 26 2019 at 14:07)</a>:</h4>
<p>oh, wait, all you need is a query that takes the <code>GlobalId</code> or w/e from miri</p>



<a name="169033481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033481">(Jun 26 2019 at 14:07)</a>:</h4>
<p>getting a <code>&amp;'tcx [mir::Body]</code> for the promoteds will be no different from the <code>promoted</code> field we have in <code>mir::Body</code> right now</p>



<a name="169033514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033514">(Jun 26 2019 at 14:07)</a>:</h4>
<p>and dispatches either to <code>optimized_mir</code> or to <code>promoted_mir</code>, in the local crate</p>



<a name="169033565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033565">(Jun 26 2019 at 14:08)</a>:</h4>
<p>that's what <code>const_eval</code> does right now ;)</p>



<a name="169033573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033573">(Jun 26 2019 at 14:08)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> you said you need to return two things</p>



<a name="169033620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033620">(Jun 26 2019 at 14:08)</a>:</h4>
<p>well, <code>promoted_mir</code> needs to emit the <code>mir::Body</code> of the main MIR, too</p>



<a name="169033628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033628">(Jun 26 2019 at 14:09)</a>:</h4>
<p>because that is modified by <code>promoted_consts</code></p>



<a name="169033643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033643">(Jun 26 2019 at 14:09)</a>:</h4>
<p>yes, that wouldn't work cross-crate, would it?</p>



<a name="169033648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033648">(Jun 26 2019 at 14:09)</a>:</h4>
<p>and then that will get stolen by <code>optimized_mir</code></p>



<a name="169033669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033669">(Jun 26 2019 at 14:09)</a>:</h4>
<p>not sure how stealing works cross crate</p>



<a name="169033684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033684">(Jun 26 2019 at 14:09)</a>:</h4>
<p>my point is that you wouldn't have anything to put there</p>



<a name="169033700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033700">(Jun 26 2019 at 14:10)</a>:</h4>
<p>since the cross-crate MIR is obtained from <code>optimized_mir</code></p>



<a name="169033811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033811">(Jun 26 2019 at 14:10)</a>:</h4>
<p>"put" where?</p>



<a name="169033850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033850">(Jun 26 2019 at 14:11)</a>:</h4>
<p>I would have assumed <code>promoted_mir</code> to return a <code>Steal</code> that when accessed will panic</p>



<a name="169033859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033859">(Jun 26 2019 at 14:11)</a>:</h4>
<p>in that return value of <code>promoted_mir(non_local_def_id)</code></p>



<a name="169033876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033876">(Jun 26 2019 at 14:11)</a>:</h4>
<p>but the <code>&amp;'tcx [mir::Body]</code> of the promoteds would still be there</p>



<a name="169033888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033888">(Jun 26 2019 at 14:11)</a>:</h4>
<p>I would've assumed that would be impossible by design :P</p>



<a name="169033901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033901">(Jun 26 2019 at 14:11)</a>:</h4>
<p>anyway, we can create another wrapper query</p>



<a name="169033913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033913">(Jun 26 2019 at 14:11)</a>:</h4>
<p>so it might be better if there was a third query, that gives you access to only <em>one</em> body at a time, given a <code>GlobalId</code>, and is implemented differently for local and cross-crate</p>



<a name="169033980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169033980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169033980">(Jun 26 2019 at 14:12)</a>:</h4>
<p>so <code>optimized_mir</code> steals the main <code>mir::Body</code> and <code>promoted_mir</code> steals the <code>&amp;'tcx [mir::Body]</code> and just returns it</p>



<a name="169034000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034000">(Jun 26 2019 at 14:12)</a>:</h4>
<p>and we have a <code>hack_promoted_mir</code> query that returns the tuple</p>



<a name="169034050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034050">(Jun 26 2019 at 14:13)</a>:</h4>
<p>not sure I like that. I'd rather have the <code>GlobalId</code> thing. hmm</p>



<a name="169034067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034067">(Jun 26 2019 at 14:13)</a>:</h4>
<p>what about optimization passes and promoted MIR?</p>



<a name="169034069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034069">(Jun 26 2019 at 14:13)</a>:</h4>
<p>that doesn't work, as promoteds can be generic</p>



<a name="169034072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034072">(Jun 26 2019 at 14:13)</a>:</h4>
<p>what would happen there</p>



<a name="169034085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034085">(Jun 26 2019 at 14:13)</a>:</h4>
<p>is promoted MIR optimized?</p>



<a name="169034105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034105">(Jun 26 2019 at 14:13)</a>:</h4>
<p>I thought it wasn't</p>



<a name="169034110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034110">(Jun 26 2019 at 14:13)</a>:</h4>
<p>today, yeah, all the passes that run on the parent body run on promoteds</p>



<a name="169034120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034120">(Jun 26 2019 at 14:13)</a>:</h4>
<p>ah</p>



<a name="169034171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034171">(Jun 26 2019 at 14:14)</a>:</h4>
<p>we should bench that</p>



<a name="169034177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034177">(Jun 26 2019 at 14:14)</a>:</h4>
<p>the pass might choose not to</p>



<a name="169034198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034198">(Jun 26 2019 at 14:14)</a>:</h4>
<p>but the pass runner throws both at every pass</p>



<a name="169034255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169034255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169034255">(Jun 26 2019 at 14:15)</a>:</h4>
<p>considering the minimalism of promoteds, we should probably just not do that</p>



<a name="169035775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169035775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169035775">(Jun 26 2019 at 14:30)</a>:</h4>
<p>What's the next step I should work on?</p>



<a name="169036022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036022">(Jun 26 2019 at 14:33)</a>:</h4>
<p>uuuh <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> do you want to touch the query changes discussed here?</p>



<a name="169036195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036195">(Jun 26 2019 at 14:35)</a>:</h4>
<p>Heh I can try</p>



<a name="169036395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036395">(Jun 26 2019 at 14:36)</a>:</h4>
<p>So we're adding a <code>promoted_mir</code> query that returns a <code>&amp;'tcx [mir::Body]</code>?</p>



<a name="169036419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036419">(Jun 26 2019 at 14:37)</a>:</h4>
<p>as a first step, you can create a <code>promoted_mir</code> query that takes a <code>DefId</code> and returns a <code>&amp;'tcx [mir::Body]</code> by calling <code>optimized_mir</code> and returning that field</p>



<a name="169036463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036463">(Jun 26 2019 at 14:37)</a>:</h4>
<p>What's going to happen with <code>Body</code>? Is it still going to have a <code>promoted</code> field?</p>



<a name="169036470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036470">(Jun 26 2019 at 14:37)</a>:</h4>
<p>for now yes</p>



<a name="169036495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036495">(Jun 26 2019 at 14:38)</a>:</h4>
<p>you can port <code>promoted</code> accessors except <code>MirPass</code>es to use the new query</p>



<a name="169036556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036556">(Jun 26 2019 at 14:38)</a>:</h4>
<p>We won't hit query cycles if <code>promoted_mir</code> calls <code>optimized_mir</code> to borrow the <code>promoted</code> field?</p>



<a name="169036608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036608">(Jun 26 2019 at 14:38)</a>:</h4>
<p>not for the places that currently call <code>optimized_mir</code> and then access the <code>promoted</code> field directly</p>



<a name="169036638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036638">(Jun 26 2019 at 14:39)</a>:</h4>
<p><code>promoted_mir</code> is essentially a "getter" at the beginning</p>



<a name="169036644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036644">(Jun 26 2019 at 14:39)</a>:</h4>
<p>Ok</p>



<a name="169036699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036699">(Jun 26 2019 at 14:40)</a>:</h4>
<p>Does <code>promoted_mir</code> need to call <code>optimized_mir</code> or just <code>const_qualifed</code>?</p>



<a name="169036824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169036824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169036824">(Jun 26 2019 at 14:41)</a>:</h4>
<p>Well, I guess that won't work because it returns a <code>Steal</code> which <code>optimized_mir</code> will have taken...</p>



<a name="169037083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037083">(Jun 26 2019 at 14:41)</a>:</h4>
<p>jup, keep calling <code>optimized_mir</code> for now</p>



<a name="169037315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037315">(Jun 26 2019 at 14:43)</a>:</h4>
<p>once there's a <code>promoted_mir_inner</code> query that returns <code>(Steal&lt;&amp;'tcx mir::Body&gt;, Steal&lt;&amp;'tcx [mir::Body]&gt;)</code> then <code>promoted_mir</code> won't have to refer to <code>optimized_mir</code> anymore and we can remove the <code>promoted</code> field</p>



<a name="169037322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037322">(Jun 26 2019 at 14:43)</a>:</h4>
<p>but for now just lay the groundwork</p>



<a name="169037898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037898">(Jun 26 2019 at 14:49)</a>:</h4>
<p>Ok got it</p>



<a name="169037921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037921">(Jun 26 2019 at 14:49)</a>:</h4>
<p>And that should be independent of the changes I showed you</p>



<a name="169037929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037929">(Jun 26 2019 at 14:49)</a>:</h4>
<p>It's just a refactoring</p>



<a name="169037951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169037951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169037951">(Jun 26 2019 at 14:49)</a>:</h4>
<p>yes</p>



<a name="169038038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038038">(Jun 26 2019 at 14:50)</a>:</h4>
<p>Ok, thanks!</p>



<a name="169038045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038045">(Jun 26 2019 at 14:50)</a>:</h4>
<p>and once that is done, making <code>ConstProp</code> use <code>InterpCx</code> for promoteds becomes trivial</p>



<a name="169038150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038150">(Jun 26 2019 at 14:51)</a>:</h4>
<p>Is there somebody in particular I should ping for reviews for the next few weeks or just let highfive do its job?</p>



<a name="169038312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038312">(Jun 26 2019 at 14:53)</a>:</h4>
<p>use highfive, it'll get reassigned appropriately if the assignment is off. You can ping <code>@rust-lang/wg-mir-opt</code> to ask for someone to pick it up</p>



<a name="169038451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038451">(Jun 26 2019 at 14:54)</a>:</h4>
<p>Perfect. Thanks!</p>



<a name="169038507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038507">(Jun 26 2019 at 14:55)</a>:</h4>
<p>Have a good trip/fun on your time off/whatever you're doing <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="169038598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038598">(Jun 26 2019 at 14:56)</a>:</h4>
<p><span aria-label="sailboat" class="emoji emoji-26f5" role="img" title="sailboat">:sailboat:</span></p>



<a name="169038603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/169038603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#169038603">(Jun 26 2019 at 14:56)</a>:</h4>
<p>thanks!</p>



<a name="170925139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925139">(Jul 15 2019 at 19:46)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> to me to this <a href="https://github.com/rust-lang/rust/pull/62322" target="_blank" title="https://github.com/rust-lang/rust/pull/62322">https://github.com/rust-lang/rust/pull/62322</a></p>



<a name="170925168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925168">(Jul 15 2019 at 19:47)</a>:</h4>
<p>saw at some point that you, <span class="user-mention" data-user-id="124288">@oli</span> and <span class="user-mention" data-user-id="119009">@eddyb</span> were discussing about the idea</p>



<a name="170925192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925192">(Jul 15 2019 at 19:47)</a>:</h4>
<p>I guess you agreed to do so?</p>



<a name="170925326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925326">(Jul 15 2019 at 19:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> Yeah, that came out of <a href="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Using.20.60InterpCx.60.20more/near/169035775" title="#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Using.20.60InterpCx.60.20more/near/169035775">https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Using.20.60InterpCx.60.20more/near/169035775</a></p>



<a name="170925367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925367">(Jul 15 2019 at 19:49)</a>:</h4>
<p>Jup, we want the promoted field to get removed from the mir::Body</p>



<a name="170925448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925448">(Jul 15 2019 at 19:50)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span>  I thought there were going to be more changes than there were. Perhaps my expectations were off or maybe I missed something...</p>



<a name="170925652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925652">(Jul 15 2019 at 19:51)</a>:</h4>
<p>ohh just saw <span class="user-mention" data-user-id="124288">@oli</span> r+, cool then so I don't have to :)</p>



<a name="170925669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925669">(Jul 15 2019 at 19:51)</a>:</h4>
<p>There aren't that many instances of <code>*.promoted </code>though so I think it's correct.</p>



<a name="170925822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925822">(Jul 15 2019 at 19:53)</a>:</h4>
<p>Jup</p>



<a name="170925973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170925973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170925973">(Jul 15 2019 at 19:54)</a>:</h4>
<p>I need to page this back into my brain to figure out what the next step is. <span class="user-mention" data-user-id="124288">@oli</span> I'll probably ping you tomorrow if that's ok to sort that out.</p>



<a name="170926792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/170926792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#170926792">(Jul 15 2019 at 20:03)</a>:</h4>
<p>I'll probably be unavailable until 18 CET or sth.</p>



<a name="171094013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171094013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171094013">(Jul 17 2019 at 16:32)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> So, looking back at the previous conversation here, I think the next step is to introduce the <code>promoted_mir_inner</code> query and remove the <code>promoted</code> field from <code>Body</code>. I've started working on that <a href="https://github.com/wesleywiser/rust/commit/bbf6eb81b4f2809d0f56102f8575b687439aa62d" target="_blank" title="https://github.com/wesleywiser/rust/commit/bbf6eb81b4f2809d0f56102f8575b687439aa62d">here</a>. My plan is to actually change <code>promote_consts::promote_candidates()</code> to return the <code>IndexVec&lt;Promoted, Body&gt;</code> of collected promoted values instead of mutating <code>Body.promoted</code>. Then in <code>mir_validated</code>, we can access those promoted values and change the <code>mir_validated</code> query to return <code>('tcx Steal&lt;Body&gt;, 'tcx Steal&lt;IndexVec&lt;Promoted, Body&gt;&gt;)</code>. With that change, I don't think we actually need the <code>promoted_mir_inner</code> query and we'll just change <code>promoted_mir</code> to query <code>mir_validated</code> and then run the optimizations on the promotions.</p>



<a name="171094020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171094020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171094020">(Jul 17 2019 at 16:32)</a>:</h4>
<p>Am I on the right track?</p>



<a name="171095427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171095427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171095427">(Jul 17 2019 at 16:51)</a>:</h4>
<p>Oh, that makes sense, good that we don't need the inner-hack</p>



<a name="171095527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171095527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171095527">(Jul 17 2019 at 16:52)</a>:</h4>
<p>Ok, cool!</p>



<a name="171095534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171095534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171095534">(Jul 17 2019 at 16:52)</a>:</h4>
<p>I wasn't sure if I was going completely off track <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="171095937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171095937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171095937">(Jul 17 2019 at 16:58)</a>:</h4>
<p>Nope, sounds great and the code lgtm</p>



<a name="171437277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171437277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171437277">(Jul 22 2019 at 14:53)</a>:</h4>
<p>So, I've been working more on this and I've come across a few things that are making this harder than I initially expected:</p>
<p>1. Many (most?) of the existing <code>MirPass</code>es operate on <code>mir::Body</code> but they have no idea what that body's <code>DefId</code> is. As a result, they can't easily call <code>tcx.promoted_mir(def_id)</code> instead of <code>body.promoted</code>. I think in general this is resolvable by passing the DefId in from the code calling into the pass but I'm not 100% sure. Perhaps the better thing to do would be to add a <code>def_id: DefId</code> property to <code>Body</code> instead of passing it in everywhere? <br>
2. Some <code>MirPass</code>es operate on both a method <code>Body</code> and it's promoted values at the same time. <a href="https://github.com/rust-lang/rust/blob/9606f6fa64926a84d82e3c62dbdc57f5c10f756d/src/librustc_mir/borrow_check/nll/renumber.rs#L47-L53" target="_blank" title="https://github.com/rust-lang/rust/blob/9606f6fa64926a84d82e3c62dbdc57f5c10f756d/src/librustc_mir/borrow_check/nll/renumber.rs#L47-L53">Example.</a> It's not clear to me if we can seperate the processing of promoted values from their parent <code>Body</code> for these passes as I think we will need to do.<br>
3. The MIR inliner actually copies promoted values from inlined methods into their callsite. I guess this is just another variant of (2) but it's throwing me for a loop. <br>
From looking back in this thread, I think the main reason we're trying to do this is to fix some wasted effort on the compiler's part. <span class="user-mention" data-user-id="124288">@oli</span> noted that we're computing promoted values during <code>ConstProp</code> but then those computed values are discarded and then later codegen recomputes the same promoted values when it needs them. </p>
<p>Perhaps there's a different, easier, way to accomplish the same thing?</p>
<p>For example, what if <code>ConstProp</code> actually replaced the promoted <code>Body</code> with something like:</p>
<div class="codehilite"><pre><span></span>bb0: {
    _0 = const {value};
    return;
}
</pre></div>


<p>I would think that would be much more efficient for codegen to process later which should get us most of the same benefits. </p>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="171454203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171454203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171454203">(Jul 22 2019 at 18:17)</a>:</h4>
<p>1. seems like you found some solutions. I'm not sure what would be better either, but having a <code>DefId</code> in the <code>Body</code> doesn't seem like the worst idea, we may be able to move some more things out of <code>Body</code> and access them via queries instead</p>



<a name="171454319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171454319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171454319">(Jul 22 2019 at 18:19)</a>:</h4>
<p>2. could be fixed by just running all <code>MirPass</code>es on promoteds, too</p>



<a name="171454332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171454332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171454332">(Jul 22 2019 at 18:19)</a>:</h4>
<p>and not do that manually in each pass</p>



<a name="171454375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171454375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171454375">(Jul 22 2019 at 18:19)</a>:</h4>
<p>oh, 3 sounds interesting</p>



<a name="171454489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171454489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171454489">(Jul 22 2019 at 18:21)</a>:</h4>
<p>We could try to evaluate all promoteds, if that doesn't work (due to generics), run const prop (and other passes) on the promoteds</p>



<a name="171455888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171455888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171455888">(Jul 22 2019 at 18:38)</a>:</h4>
<blockquote>
<p>1. seems like you found some solutions. I'm not sure what would be better either, but having a <code>DefId</code> in the <code>Body</code> doesn't seem like the worst idea, we may be able to move some more things out of <code>Body</code> and access them via queries instead</p>
</blockquote>
<p>I guess a different approach would be to give each promoted a unique id and that would be the key of the <code>promoted_mir</code> query.</p>



<a name="171455896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171455896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171455896">(Jul 22 2019 at 18:38)</a>:</h4>
<p>That doesn't seem any better to me though</p>



<a name="171456019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456019">(Jul 22 2019 at 18:39)</a>:</h4>
<blockquote>
<p>2. could be fixed by just running all <code>MirPass</code>es on promoteds, too</p>
</blockquote>
<p>Yeah, that's what I was thinking.</p>



<a name="171456179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456179">(Jul 22 2019 at 18:40)</a>:</h4>
<blockquote>
<p>oh, 3 sounds interesting</p>
</blockquote>
<p>So, I think the real issue with 3 is that <code>promoted_mir(x)</code> will depend on <code>optimized_mir(x)</code> which then depends on <code>promoted_mir(x)</code> again.</p>



<a name="171456202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456202">(Jul 22 2019 at 18:40)</a>:</h4>
<p>Because inlining can change the promoted values in a body</p>



<a name="171456362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456362">(Jul 22 2019 at 18:42)</a>:</h4>
<p>why does promoted_mir(x) depend on optimized_mir(x)?</p>



<a name="171456563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456563">(Jul 22 2019 at 18:44)</a>:</h4>
<p>optimized_mir will (theoretically) run the inliner which can pull promoted mir from an inlined method into the call site. So the promoted_mir(callsite) depends on first running the inliner at callsite.</p>



<a name="171456605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171456605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171456605">(Jul 22 2019 at 18:44)</a>:</h4>
<p>Because promoted_mir(callsite) can't change it's value after the first time it's called</p>



<a name="171458063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171458063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171458063">(Jul 22 2019 at 19:02)</a>:</h4>
<p>oh</p>



<a name="171458065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171458065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171458065">(Jul 22 2019 at 19:02)</a>:</h4>
<p>that query</p>



<a name="171458072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171458072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171458072">(Jul 22 2019 at 19:02)</a>:</h4>
<p>I thought <code>3</code> would eliminate it?</p>



<a name="171458235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171458235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171458235">(Jul 22 2019 at 19:04)</a>:</h4>
<p>I'm not sure what to do about <code>3</code></p>



<a name="171458260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/171458260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#171458260">(Jul 22 2019 at 19:05)</a>:</h4>
<p>(There was supposed to be a paragraph break after <code>3</code> but it seems to have been removed)</p>



<a name="172473468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172473468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172473468">(Aug 05 2019 at 02:24)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I've made a fair bit of progress on this I think. I've now gotten rid of the <code>promoted</code> field on <code>mir::Body</code> entirely and the compiler bootstraps without ICEing to stage 1 (after many unsuccessful attempts). I can see there's some UI tests failing related to additional errors being emitted from const eval but I'm not sure what I did that would have changed anything there. <a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1">https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1</a></p>



<a name="172483876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172483876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172483876">(Aug 05 2019 at 07:16)</a>:</h4>
<p>sweet.</p>



<a name="172483880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172483880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172483880">(Aug 05 2019 at 07:16)</a>:</h4>
<p>I guess we can get rid of this hack now: <a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-9e103702275cbef342c2decd3395bf3bL398" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-9e103702275cbef342c2decd3395bf3bL398">https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-9e103702275cbef342c2decd3395bf3bL398</a></p>



<a name="172484163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172484163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172484163">(Aug 05 2019 at 07:23)</a>:</h4>
<p>no need for an option in <a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-c2552a106550d05b69d5e07612f0f812R1510" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-c2552a106550d05b69d5e07612f0f812R1510">https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-c2552a106550d05b69d5e07612f0f812R1510</a> just use an empty IndexVec</p>



<a name="172484484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172484484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172484484">(Aug 05 2019 at 07:31)</a>:</h4>
<p>wrt your additional errors. Maybe they're happening because all MirPasses are now run on promoteds (before copy prop sees them)</p>



<a name="172484511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172484511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172484511">(Aug 05 2019 at 07:32)</a>:</h4>
<p>about inlining (<a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-04789deb41c6e9576b3942e6a92e5551R430" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-04789deb41c6e9576b3942e6a92e5551R430">https://github.com/rust-lang/rust/compare/master...wesleywiser:remove_promoted_field?expand=1#diff-04789deb41c6e9576b3942e6a92e5551R430</a>) I think the only actionable solution is to change the <code>StaticKind::Promoted</code> to also have a field with the <code>DefId</code></p>



<a name="172484555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172484555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172484555">(Aug 05 2019 at 07:32)</a>:</h4>
<p>at which point we can pull the <code>DefId</code>s out of the <code>StaticKInd</code> enum and put it into the surrounding value</p>



<a name="172578029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172578029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172578029">(Aug 06 2019 at 10:58)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> </p>
<blockquote>
<p>I guess we can get rid of this hack now</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/commit/1090ef613c586d502dfad0e2d8023ad470d78b60" target="_blank" title="https://github.com/rust-lang/rust/commit/1090ef613c586d502dfad0e2d8023ad470d78b60">Done</a></p>
<blockquote>
<p>no need for an option in </p>
</blockquote>
<p>This is easy. I'll circle back to this later.</p>
<blockquote>
<p>wrt your additional errors. Maybe they're happening because all MirPasses are now run on promoteds (before copy prop sees them)</p>
</blockquote>
<p>Maybe? I don't really understand why copy prop would have an effect here.</p>
<blockquote>
<p>about inlining </p>
</blockquote>
<p>I <a href="https://github.com/rust-lang/rust/commit/6e4552078415d3d901db378697093f54ddbf11d3" target="_blank" title="https://github.com/rust-lang/rust/commit/6e4552078415d3d901db378697093f54ddbf11d3">started making these changes</a>. How does this handle polymorphic promoted values? If I have this:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">make</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="nb">&#39;static</span><span class="w"> </span><span class="p">[</span><span class="n">T</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="o">&amp;</span><span class="p">[]</span><span class="w"> </span><span class="c1">//promoted[0] in  make: [T; 0]</span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">make</span><span class="o">&lt;</span><span class="n">B</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>then when we inline <code>make</code> into <code>test</code>, <code>promoted[0]</code> will still have the <code>DefId</code> of <code>make</code> but it won't have any <code>Substs</code>. So when codegen (for example) runs, how does it know to use <code>B</code> for <code>T</code> instead of <code>A</code>?</p>



<a name="172580892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172580892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172580892">(Aug 06 2019 at 11:49)</a>:</h4>
<p>we can do the same thing that <code>Unevaluated</code> does and add a field for <code>SubstsRef</code></p>



<a name="172580946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172580946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172580946">(Aug 06 2019 at 11:50)</a>:</h4>
<p>these will need to have gotten adjusted for the calling function's substs, so you'd have to substitute substitutions</p>



<a name="172589069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/172589069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#172589069">(Aug 06 2019 at 13:41)</a>:</h4>
<blockquote>
<p>these will need to have gotten adjusted for the calling function's substs, so you'd have to substitute substitutions</p>
</blockquote>
<p><span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> </p>
<p>That makes sense. Thanks!</p>



<a name="173114191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114191">(Aug 13 2019 at 13:45)</a>:</h4>
<blockquote>
<p>these will need to have gotten adjusted for the calling function's substs, so you'd have to substitute substitutions</p>
</blockquote>
<p>So I've been working on this but I'm not really sure how to do that and I don't see any functions <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/type.InternalSubsts.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/type.InternalSubsts.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/type.InternalSubsts.html</a> that seem to do that. Any pointers?</p>



<a name="173114309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114309">(Aug 13 2019 at 13:47)</a>:</h4>
<p>Oh, wait, is that what <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/relate/trait.Relate.html#tymethod.relate" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/relate/trait.Relate.html#tymethod.relate">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/relate/trait.Relate.html#tymethod.relate</a> is for?</p>



<a name="173114401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114401">(Aug 13 2019 at 13:48)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> that's because that method is on a trait: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/trait.Subst.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/trait.Subst.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/subst/trait.Subst.html</a></p>



<a name="173114412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114412">(Aug 13 2019 at 13:49)</a>:</h4>
<p>super confusing name combo</p>



<a name="173114419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114419">(Aug 13 2019 at 13:49)</a>:</h4>
<p>Yeah, it was hidden under the fold</p>



<a name="173114436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114436">(Aug 13 2019 at 13:49)</a>:</h4>
<p>Is <code>Relate::relate()</code> what I'm looking for?</p>



<a name="173114455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114455">(Aug 13 2019 at 13:49)</a>:</h4>
<p>no, you can just call <code>subst</code> directly</p>



<a name="173114538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114538">(Aug 13 2019 at 13:50)</a>:</h4>
<p>That method should be called loads in the inlining code</p>



<a name="173114540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114540">(Aug 13 2019 at 13:50)</a>:</h4>
<p>or I'm doing something wrong</p>



<a name="173114547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114547">(Aug 13 2019 at 13:50)</a>:</h4>
<p>lemme check before I'm talking more nonsense</p>



<a name="173114580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114580">(Aug 13 2019 at 13:51)</a>:</h4>
<p>No I think you're right</p>



<a name="173114597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114597">(Aug 13 2019 at 13:51)</a>:</h4>
<p>For example <a href="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/transform/inline.rs#L312" target="_blank" title="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/transform/inline.rs#L312">https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/transform/inline.rs#L312</a></p>



<a name="173114603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114603">(Aug 13 2019 at 13:51)</a>:</h4>
<p>ah perfect</p>



<a name="173114608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114608">(Aug 13 2019 at 13:52)</a>:</h4>
<p>So I'll need to call it in the inliner as well</p>



<a name="173114652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114652">(Aug 13 2019 at 13:52)</a>:</h4>
<p>I screwed up substitutions badly just last week and @eddyb had to dig me out of my hole</p>



<a name="173114662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114662">(Aug 13 2019 at 13:52)</a>:</h4>
<p>And then also in the collector because the inliner is still running on polymorphic MIR right?</p>



<a name="173114682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114682">(Aug 13 2019 at 13:52)</a>:</h4>
<p>the collector already monomorphizes</p>



<a name="173114718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114718">(Aug 13 2019 at 13:53)</a>:</h4>
<p>you don't need to change anything there I believe</p>



<a name="173114727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114727">(Aug 13 2019 at 13:53)</a>:</h4>
<p>Well I think it just uses <code>collect_neighbors()</code></p>



<a name="173114747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114747">(Aug 13 2019 at 13:53)</a>:</h4>
<p>Don't I need to move the collection to <a href="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L674" target="_blank" title="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L674">https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L674</a></p>



<a name="173114750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114750">(Aug 13 2019 at 13:53)</a>:</h4>
<p>?</p>



<a name="173114803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114803">(Aug 13 2019 at 13:54)</a>:</h4>
<p>Since that's where the correct <code>DefId</code> and <code>SubstsRef</code> will be in scope</p>



<a name="173114963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114963">(Aug 13 2019 at 13:56)</a>:</h4>
<p>phew, you scared me a bit</p>



<a name="173114971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114971">(Aug 13 2019 at 13:56)</a>:</h4>
<p>the current code does the right thing because <a href="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L1238" target="_blank" title="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L1238">https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/monomorphize/collector.rs#L1238</a> has the substs with it</p>



<a name="173114976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173114976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173114976">(Aug 13 2019 at 13:56)</a>:</h4>
<p><span aria-label="sweat" class="emoji emoji-1f613" role="img" title="sweat">:sweat:</span></p>



<a name="173115072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115072">(Aug 13 2019 at 13:57)</a>:</h4>
<p>Yeah, but because we've split out the promoted MIR from <code>Body</code>, you can't just do what <code>collect_neighbors()</code> is doing because your function might reference promoted MIR from an inlined function and that won't be returned by <code>tcx.promoted_mir(your_body_def_id)</code></p>



<a name="173115129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115129">(Aug 13 2019 at 13:58)</a>:</h4>
<p>yea lol I just wrote a big text and realized I'm stupid</p>



<a name="173115160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115160">(Aug 13 2019 at 13:58)</a>:</h4>
<p>Nah, it's fine. I just want to make sure I'm not doing something dumb either</p>



<a name="173115164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115164">(Aug 13 2019 at 13:58)</a>:</h4>
<p>so... how does your <code>StaticKind</code> type look right now?</p>



<a name="173115173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115173">(Aug 13 2019 at 13:58)</a>:</h4>
<p>what info does it propagate?</p>



<a name="173115184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115184">(Aug 13 2019 at 13:58)</a>:</h4>
<p>(Should have pushed my changes this morning)</p>



<a name="173115241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115241">(Aug 13 2019 at 13:59)</a>:</h4>
<p>There's a <code>DefId</code> of the root owner function of the promoted and the already adjusted <code>Substs</code>, right?</p>



<a name="173115334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115334">(Aug 13 2019 at 14:00)</a>:</h4>
<p>so you can create an <code>Instance</code> from this information, but you're right, you need to subst the substs with <code>param_substs</code> before you do</p>



<a name="173115355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115355">(Aug 13 2019 at 14:00)</a>:</h4>
<p>It's roughly</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Static</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">ty</span>: <span class="nc">Ty</span><span class="o">&lt;</span><span class="na">&#39;tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">kind</span>: <span class="nc">StaticKind</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="n">def_id</span>: <span class="nc">DefId</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">enum</span> <span class="nc">StaticKind</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Promoted</span><span class="p">(</span><span class="n">Promoted</span><span class="p">,</span><span class="w"> </span><span class="n">SubstsRef</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Static</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="173115374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115374">(Aug 13 2019 at 14:00)</a>:</h4>
<p>ah yes, perfect</p>



<a name="173115460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115460">(Aug 13 2019 at 14:01)</a>:</h4>
<p>So I should do the <code>subst()</code> call in the inliner to correct for any substs at the call site and then again in the collector for any final substs</p>



<a name="173115469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115469">(Aug 13 2019 at 14:01)</a>:</h4>
<p>yes</p>



<a name="173115504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115504">(Aug 13 2019 at 14:02)</a>:</h4>
<p>Cool</p>



<a name="173115546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115546">(Aug 13 2019 at 14:02)</a>:</h4>
<p>I think (hopefully) this is almost finished</p>



<a name="173115554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115554">(Aug 13 2019 at 14:02)</a>:</h4>
<p>sweet</p>



<a name="173115599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115599">(Aug 13 2019 at 14:03)</a>:</h4>
<p>Thanks for your help!</p>



<a name="173115614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115614">(Aug 13 2019 at 14:03)</a>:</h4>
<p>I think we kinda reinvented <code>ty::Const { val: ConstValue::Unevaluated(did, substs), ty }</code>, but that's alright, we can merge those later</p>



<a name="173115663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115663">(Aug 13 2019 at 14:04)</a>:</h4>
<p>Yeah, that looks very similar and I think I saw code in <code>const_eval_raw_provider</code> that does exactly what we want in that case.</p>



<a name="173115721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115721">(Aug 13 2019 at 14:04)</a>:</h4>
<p>yea <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="173115735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115735">(Aug 13 2019 at 14:04)</a>:</h4>
<p>and inlining will also do the right thing automatically I think</p>



<a name="173115743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115743">(Aug 13 2019 at 14:04)</a>:</h4>
<p>because it already has logic for constants</p>



<a name="173115766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115766">(Aug 13 2019 at 14:04)</a>:</h4>
<p>I should look at that then.</p>



<a name="173115801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115801">(Aug 13 2019 at 14:05)</a>:</h4>
<p>Aren't constants always monomorphic though?</p>



<a name="173115811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115811">(Aug 13 2019 at 14:05)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/52c6458320d268d0b5a0b92d67f1fe943c7be518/src/librustc_mir/interpret/operand.rs#L515" target="_blank" title="https://github.com/rust-lang/rust/blob/52c6458320d268d0b5a0b92d67f1fe943c7be518/src/librustc_mir/interpret/operand.rs#L515">https://github.com/rust-lang/rust/blob/52c6458320d268d0b5a0b92d67f1fe943c7be518/src/librustc_mir/interpret/operand.rs#L515</a></p>



<a name="173115820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115820">(Aug 13 2019 at 14:05)</a>:</h4>
<p>not if they are associated constants of arrays</p>



<a name="173115861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115861">(Aug 13 2019 at 14:05)</a>:</h4>
<p>Your commit hash doesn't seem to exist <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="173115929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173115929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173115929">(Aug 13 2019 at 14:06)</a>:</h4>
<p><span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span> grab it on master then</p>



<a name="173116196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116196">(Aug 13 2019 at 14:09)</a>:</h4>
<p>Ok yeah it does that too <a href="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/interpret/operand.rs#L546-L551" target="_blank" title="https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/interpret/operand.rs#L546-L551">https://github.com/rust-lang/rust/blob/60960a260f7b5c695fd0717311d72ce62dd4eb43/src/librustc_mir/interpret/operand.rs#L546-L551</a></p>



<a name="173116639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116639">(Aug 13 2019 at 14:13)</a>:</h4>
<p>sorry, my IDE jumped between files</p>



<a name="173116652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116652">(Aug 13 2019 at 14:13)</a>:</h4>
<p>that link was entirely bogus</p>



<a name="173116658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116658">(Aug 13 2019 at 14:13)</a>:</h4>
<p>I meant to link into the interner</p>



<a name="173116964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116964">(Aug 13 2019 at 14:16)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> here's the right link: <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/inline.rs#L121" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/inline.rs#L121">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/inline.rs#L121</a></p>



<a name="173116970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116970">(Aug 13 2019 at 14:16)</a>:</h4>
<p>so I guess you don't need to subst anything at all</p>



<a name="173116973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116973">(Aug 13 2019 at 14:17)</a>:</h4>
<p>it's already substituted</p>



<a name="173116990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173116990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173116990">(Aug 13 2019 at 14:17)</a>:</h4>
<p>and if you repeat the substitution, you'd probably get an ICE</p>



<a name="173117015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173117015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173117015">(Aug 13 2019 at 14:17)</a>:</h4>
<p>Gotcha</p>



<a name="173117017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173117017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173117017">(Aug 13 2019 at 14:17)</a>:</h4>
<p>Thanks!</p>



<a name="173193188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173193188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173193188">(Aug 14 2019 at 11:09)</a>:</h4>
<p>you've probably already seen them but in case not, these PRs seem relevant for your discussion:<br>
<a href="https://github.com/rust-lang/rust/pull/63495" target="_blank" title="https://github.com/rust-lang/rust/pull/63495">https://github.com/rust-lang/rust/pull/63495</a><br>
<a href="https://github.com/rust-lang/rust/pull/63497" target="_blank" title="https://github.com/rust-lang/rust/pull/63497">https://github.com/rust-lang/rust/pull/63497</a></p>



<a name="173367726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367726">(Aug 16 2019 at 12:05)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="124288">@oli</span> <span aria-label="wave" class="emoji emoji-1f44b" role="img" title="wave">:wave:</span></p>



<a name="173367751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367751">(Aug 16 2019 at 12:06)</a>:</h4>
<p>hi</p>



<a name="173367813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367813">(Aug 16 2019 at 12:07)</a>:</h4>
<p>I was looking at the <code>SubstFolder</code> per your comment and it doesn't look like it does anything with promoted MIR at all</p>



<a name="173367826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367826">(Aug 16 2019 at 12:07)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L451" target="_blank" title="https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L451">https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L451</a></p>



<a name="173367872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367872">(Aug 16 2019 at 12:08)</a>:</h4>
<p>Reading through,  I don't think it even touches MIR at all</p>



<a name="173367887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367887">(Aug 16 2019 at 12:08)</a>:</h4>
<p>Am I looking at the right thing?</p>



<a name="173367906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367906">(Aug 16 2019 at 12:09)</a>:</h4>
<p>I only found one implementation of <code>trait Subst</code> and it's here so I think this is the right code</p>



<a name="173367910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173367910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173367910">(Aug 16 2019 at 12:09)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L420" target="_blank" title="https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L420">https://github.com/rust-lang/rust/blob/5a6d801bf9399004a0f0a19e510d996f4686c093/src/librustc/ty/subst.rs#L420</a></p>



<a name="173368002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368002">(Aug 16 2019 at 12:11)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> <a href="https://github.com/rust-lang/rust/blob/1df512fcaeaf17639c5d28a3045814d6f7a7db97/src/librustc/mir/mod.rs#L3231" target="_blank" title="https://github.com/rust-lang/rust/blob/1df512fcaeaf17639c5d28a3045814d6f7a7db97/src/librustc/mir/mod.rs#L3231">https://github.com/rust-lang/rust/blob/1df512fcaeaf17639c5d28a3045814d6f7a7db97/src/librustc/mir/mod.rs#L3231</a> is wrong probably</p>



<a name="173368074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368074">(Aug 16 2019 at 12:12)</a>:</h4>
<p>Oh, gotcha. <code>self.fold_with()</code> dispatches via <code>TypeFoldable</code>.</p>



<a name="173368075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368075">(Aug 16 2019 at 12:12)</a>:</h4>
<p>it probably was always wrong... the type should have been folded at least</p>



<a name="173368083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368083">(Aug 16 2019 at 12:12)</a>:</h4>
<p>but now we need to fold the substs, too</p>



<a name="173368085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368085">(Aug 16 2019 at 12:12)</a>:</h4>
<p>same goes for the <code>visit</code> part</p>



<a name="173368087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368087">(Aug 16 2019 at 12:12)</a>:</h4>
<p>Ok <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="173368110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368110">(Aug 16 2019 at 12:13)</a>:</h4>
<p>I think I can probably go from there</p>



<a name="173368114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368114">(Aug 16 2019 at 12:13)</a>:</h4>
<p>Sorry to bug you</p>



<a name="173368326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/173368326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#173368326">(Aug 16 2019 at 12:17)</a>:</h4>
<p>no worries at all, please do ask!</p>



<a name="174147678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174147678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174147678">(Aug 26 2019 at 14:44)</a>:</h4>
<p>Yay <a href="https://github.com/rust-lang/rust/issues/63580" target="_blank" title="https://github.com/rust-lang/rust/issues/63580">#63580</a> got merged! <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="174148002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174148002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174148002">(Aug 26 2019 at 14:48)</a>:</h4>
<p>I'm starting to look into replacing <a href="https://github.com/rust-lang/rust/blob/555d7a2fd6165b614cfc01136d8e3f5c465a1582/src/librustc_mir/transform/const_prop.rs#L342" target="_blank" title="https://github.com/rust-lang/rust/blob/555d7a2fd6165b614cfc01136d8e3f5c465a1582/src/librustc_mir/transform/const_prop.rs#L342"><code>ConstProp::const_prop()</code></a> with use of <code>InterpCx</code>which I think is now unblocked because we fixed the promoted issue.</p>



<a name="174148990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174148990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174148990">(Aug 26 2019 at 15:00)</a>:</h4>
<p>We will have the best const propagator on the planet, you should totally hold a talk about const prop at some point.</p>



<a name="174149030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149030">(Aug 26 2019 at 15:00)</a>:</h4>
<p>That would be fun</p>



<a name="174149056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149056">(Aug 26 2019 at 15:00)</a>:</h4>
<p>I mean... what other language reports warnings on failing to apply optimizations....</p>



<a name="174149077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149077">(Aug 26 2019 at 15:01)</a>:</h4>
<p>I'm on the hunt for a talk to propose for a Rust conference next year anyway <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="174149097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149097">(Aug 26 2019 at 15:01)</a>:</h4>
<p>I'm really sorry I missed your RustConf talk, it looked super interesting!</p>



<a name="174149572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149572">(Aug 26 2019 at 15:06)</a>:</h4>
<p>It was loads of fun</p>



<a name="174149647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149647">(Aug 26 2019 at 15:07)</a>:</h4>
<p>I caught bits &amp; pieces on Twitter. The stuff on compile time UB looked really interesting! Do you post your slides online?</p>



<a name="174149843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149843">(Aug 26 2019 at 15:09)</a>:</h4>
<p>The talk was recorded</p>



<a name="174149927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149927">(Aug 26 2019 at 15:10)</a>:</h4>
<p>Oh, sweet</p>



<a name="174149935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149935">(Aug 26 2019 at 15:10)</a>:</h4>
<p>Will get uploaded and slides will be available for download</p>



<a name="174149969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174149969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174149969">(Aug 26 2019 at 15:10)</a>:</h4>
<p>I'm subscribed to the YT channel so I assume it will pop up sooner or later on there</p>



<a name="174159748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174159748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174159748">(Aug 26 2019 at 17:17)</a>:</h4>
<p>looking forward to watching that talk as well :)</p>



<a name="174845917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174845917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174845917">(Sep 04 2019 at 02:16)</a>:</h4>
<p>I've got a small patch that replaces <code>ConstProp::eval_place()</code> with <code>InterpCx::eval_place_into_op()</code> and it seems to work great. However, there's a few UI tests that had to be changed because a few places where we were already emitting an error (or errors) now emit an additional error. Is that ok or do we have to match the current behavior? </p>
<p>My branch with the test changes is <a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:const_prop_use_ecx" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:const_prop_use_ecx">here</a>.</p>



<a name="174851821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174851821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174851821">(Sep 04 2019 at 05:06)</a>:</h4>
<p>We need to figure out a way to remove duplicate errors, but I'm not sure how</p>



<a name="174851895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174851895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174851895">(Sep 04 2019 at 05:08)</a>:</h4>
<p>The two cases look OK to me. Once we figure out how to fix them it should all work</p>



<a name="174879739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174879739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174879739">(Sep 04 2019 at 13:11)</a>:</h4>
<p>Do you think I should switch and focus on trying to find a solution to those errors or just keep going with the const prop changes? </p>
<p>Can we merge the const prop changes with duplicate errors or do they need to be resolved before that can happen?</p>



<a name="174910874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174910874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174910874">(Sep 04 2019 at 18:53)</a>:</h4>
<p>Nah, we can merge them. They are not worse than what we have and the code deduplication is so <span aria-label="ok" class="emoji emoji-1f44c" role="img" title="ok">:ok:</span></p>



<a name="174911157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174911157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174911157">(Sep 04 2019 at 18:55)</a>:</h4>
<p>I don't think it needs to be a focus. Cleaning up const prop should make it easier to fix them at some point</p>



<a name="174911388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174911388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174911388">(Sep 04 2019 at 18:57)</a>:</h4>
<p>Ok, I'll keep moving forward then.</p>



<a name="174911391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/174911391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#174911391">(Sep 04 2019 at 18:57)</a>:</h4>
<p>Thanks!</p>



<a name="175423462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175423462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175423462">(Sep 11 2019 at 11:57)</a>:</h4>
<p>So I've got a series of commits <a href="https://github.com/rust-lang/rust/compare/master...wesleywiser:const_prop_use_ecx" target="_blank" title="https://github.com/rust-lang/rust/compare/master...wesleywiser:const_prop_use_ecx">here</a> which I think are almost ready to go, but I'm stuck on the <code>Rvalue::Ref</code> handling. If I apply the <a href="https://github.com/rust-lang/rust/commit/9ec5f46ea2c09728375f6a21a78803f46bfbcb9f" target="_blank" title="https://github.com/rust-lang/rust/commit/9ec5f46ea2c09728375f6a21a78803f46bfbcb9f">last commit</a>, then I get test failures related to generator layout optimization. These are the failing tests:</p>
<div class="codehilite"><pre><span></span>    [ui] ui/async-await/async-await.rs
    [ui] ui/async-await/async-closure.rs
    [ui] ui/async-await/async-fn-send-uses-nonsend.rs
    [ui] ui/async-await/async-fn-size-moved-locals.rs
    [ui] ui/async-await/async-fn-size.rs
    [ui] ui/async-await/conditional-and-guaranteed-initialization.rs
    [ui] ui/async-await/drop-order/drop-order-for-locals-when-cancelled.rs
    [ui] ui/async-await/drop-order/drop-order-when-cancelled.rs
    [ui] ui/async-await/generics-and-bounds.rs
    [ui] ui/async-await/issue-60709.rs
    [ui] ui/async-await/issue-61793.rs
    [ui] ui/async-await/issue-62658.rs
    [ui] ui/async-await/issues/issue-55809.rs
    [ui] ui/async-await/issues/issue-61986.rs
    [ui] ui/async-await/move-part-await-return-rest-struct.rs
    [ui] ui/async-await/move-part-await-return-rest-tuple.rs
    [ui] ui/drop/dynamic-drop-async.rs
    [ui] ui/generator/control-flow.rs
    [ui] ui/generator/drop-and-replace.rs
    [ui] ui/generator/issue-44197.rs
    [ui] ui/generator/issue-52398.rs
    [ui] ui/generator/issue-57084.rs
    [ui] ui/generator/issue-58888.rs
    [ui] ui/generator/iterator-count.rs
    [ui] ui/generator/nested_generators.rs
    [ui] ui/generator/overlap-locals.rs
    [ui] ui/generator/static-generators.rs
    [ui] ui/generator/yield-in-box.rs
    [ui] ui/proc-macro/invalid-punct-ident-1.rs
    [ui] ui/proc-macro/invalid-punct-ident-2.rs
    [ui] ui/proc-macro/invalid-punct-ident-3.rs
    [ui] ui/unsized-locals/autoderef.rs
</pre></div>


<p>and most of them fail with something like this:</p>
<div class="codehilite"><pre><span></span>error[E0391]: cycle detected when computing layout of `[generator@src/test/ui/generator/control-flow.rs:26:15: 30:6 {fn(std::ops::Range&lt;i32&gt;) -&gt; &lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::IntoIter {&lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::into_iter}, i32, std::ops::Range&lt;i32&gt;, ()}]`
  |
note: ...which requires processing `main::{{closure}}#1`...
 --&gt; src/test/ui/generator/control-flow.rs:27:18
  |
27|         for _ in 0..8 {
  |                  ^^^^
  = note: ...which again requires computing layout of `[generator@src/test/ui/generator/control-flow.rs:26:15: 30:6 {fn(std::ops::Range&lt;i32&gt;) -&gt; &lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::IntoIter {&lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::into_iter}, i32, std::ops::Range&lt;i32&gt;, ()}]`, completing the cycle
note: cycle used when processing `main`
 --&gt; src/test/ui/generator/control-flow.rs:24:1
  |
24| fn main() {
  | ^^^^^^^^^

thread &#39;rustc&#39; panicked at &#39;aborting due to `-Z treat-err-as-bug=1`&#39;, src/librustc_errors/lib.rs:540:13
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
   1: backtrace::backtrace::trace_unsynchronized
   2: std::sys_common::backtrace::_print
   3: std::sys_common::backtrace::print
   4: std::panicking::default_hook::{{closure}}
   5: std::panicking::default_hook
   6: &lt;alloc::boxed::Box&lt;F&gt; as core::ops::function::Fn&lt;A&gt;&gt;::call
   7: rustc::util::common::panic_hook
   8: std::panicking::rust_panic_with_hook
   9: std::panicking::begin_panic
  10: rustc_errors::Handler::panic_if_treat_err_as_bug
  11: rustc_errors::Handler::bump_err_count
  12: rustc_errors::Handler::emit_db
  13: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  14: rustc::ty::query::&lt;impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::layout_raw&gt;::handle_cycle_error
  15: rustc::ty::query::plumbing::JobOwner&lt;Q&gt;::try_get::{{closure}}
  16: rustc_data_structures::cold_path
  17: rustc::ty::query::plumbing::JobOwner&lt;Q&gt;::try_get
  18: rustc::ty::query::plumbing::&lt;impl rustc::ty::context::TyCtxt&gt;::get_query
  19: rustc::ty::query::TyCtxtAt::layout_raw
             at src/librustc/ty/query/plumbing.rs:1076
  20: &lt;rustc::ty::layout::LayoutCx&lt;rustc::ty::query::TyCtxtAt&gt; as rustc_target::abi::LayoutOf&gt;::layout_of
             at src/librustc/ty/layout.rs:1965
  21: rustc::ty::layout::&lt;impl rustc::ty::query::TyCtxtAt&gt;::layout_of
             at ./src/librustc/ty/layout.rs:2012
  22: &lt;rustc_mir::interpret::eval_context::InterpCx&lt;M&gt; as rustc_target::abi::LayoutOf&gt;::layout_of
             at src/librustc_mir/interpret/eval_context.rs:191
  23: rustc_mir::interpret::place::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::ref_to_mplace
             at src/librustc_mir/interpret/place.rs:295
  24: rustc_mir::interpret::place::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::deref_operand
             at src/librustc_mir/interpret/place.rs:321
  25: rustc_mir::interpret::place::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::place_projection
             at src/librustc_mir/interpret/place.rs:584
  26: rustc_mir::interpret::place::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::eval_place::{{closure}}
             at src/librustc_mir/interpret/place.rs:695
  27: rustc::mir::Place::iterate_over::iterate_over2
  28: rustc::mir::Place::iterate_over::iterate_over2
  29: rustc::mir::Place::iterate_over::iterate_over2
  30: rustc::mir::Place::iterate_over::iterate_over2
  31: rustc::mir::Place::iterate_over::iterate_over2
  32: rustc::mir::Place::iterate_over
  33: rustc::mir::Place::iterate
  34: rustc_mir::interpret::place::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::eval_place
             at src/librustc_mir/interpret/place.rs:660
  35: rustc_mir::interpret::step::&lt;impl rustc_mir::interpret::eval_context::InterpCx&lt;M&gt;&gt;::eval_rvalue_into_place
             at src/librustc_mir/interpret/step.rs:247
  36: rustc_mir::transform::const_prop::ConstPropagator::const_prop::{{closure}}
             at src/librustc_mir/transform/const_prop.rs:319
  37: rustc_mir::transform::const_prop::ConstPropagator::use_ecx
             at src/librustc_mir/transform/const_prop.rs:237
  38: rustc_mir::transform::const_prop::ConstPropagator::const_prop
             at src/librustc_mir/transform/const_prop.rs:318
  39: &lt;rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor&gt;::visit_statement
             at src/librustc_mir/transform/const_prop.rs:569
  40: rustc::mir::visit::MutVisitor::super_basic_block_data
  41: rustc::mir::visit::MutVisitor::visit_basic_block_data
  42: rustc::mir::visit::MutVisitor::super_body
  43: rustc::mir::visit::MutVisitor::visit_body
  44: &lt;rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass&gt;::run_pass
             at src/librustc_mir/transform/const_prop.rs:93
  45: rustc_mir::transform::run_passes::{{closure}}
             at src/librustc_mir/transform/mod.rs:173
  46: rustc_mir::transform::run_passes
             at src/librustc_mir/transform/mod.rs:180
  47: rustc_mir::transform::run_optimization_passes
             at src/librustc_mir/transform/mod.rs:228
  48: rustc_mir::transform::optimized_mir
             at src/librustc_mir/transform/mod.rs:300
  49: rustc::ty::query::&lt;impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir&gt;::compute
  50: rustc::dep_graph::graph::DepGraph::with_task_impl
  51: rustc::dep_graph::graph::DepGraph::with_task
  52: rustc::ty::query::plumbing::&lt;impl rustc::ty::context::TyCtxt&gt;::force_query_with_job::{{closure}}::{{closure}}
  53: rustc::ty::query::plumbing::&lt;impl rustc::ty::context::TyCtxt&gt;::start_query::{{closure}}::{{closure}}
  54: rustc::ty::context::tls::enter_context::{{closure}}
  55: rustc::ty::context::tls::set_tlv
  56: rustc::ty::context::tls::enter_context
  57: rustc::ty::query::plumbing::&lt;impl rustc::ty::context::TyCtxt&gt;::start_query::{{closure}}
</pre></div>


<p><span class="user-mention" data-user-id="124288">@oli</span> any idea what I should do with this cycle?</p>



<a name="175424085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424085">(Sep 11 2019 at 12:06)</a>:</h4>
<p>I tried pushing the <code>place_layout</code> we have from <code>ConstProp::const_prop()</code> further down and providing it to <code>InterpCx::eval_rvalue_into_place()</code> but that didn't pan out because the <code>Place</code> containing the generator has a series of projections and <code>layout_of</code> is getting called for one of the intermediate projections so the <code>place_layout</code> we have only applies to the final projection.</p>



<a name="175424159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424159">(Sep 11 2019 at 12:06)</a>:</h4>
<p>So I'm assuming this <code>optimized_mir</code> invocation happens because of a <code>layout_of</code> invocation</p>



<a name="175424169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424169">(Sep 11 2019 at 12:06)</a>:</h4>
<p>do you have the query stack available?</p>



<a name="175424193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424193">(Sep 11 2019 at 12:07)</a>:</h4>
<p>Oh yeah, sorry. It got cutt off when I pasted the stack trace</p>



<a name="175424204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424204">(Sep 11 2019 at 12:07)</a>:</h4>
<div class="codehilite"><pre><span></span>query stack during panic:
#0 [optimized_mir] processing `main::{{closure}}#1`
#1 [layout_raw] computing layout of `[generator@src/test/ui/generator/control-flow.rs:26:15: 30:6 {fn(std::ops::Range&lt;i32&gt;) -&gt; &lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::IntoIter {&lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::into_iter}, i32, std::ops::Range&lt;i32&gt;, ()}]`
#2 [optimized_mir] processing `main`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
</pre></div>



<a name="175424247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424247">(Sep 11 2019 at 12:07)</a>:</h4>
<p>though I wonder why generators would be more special compared with plain closures</p>



<a name="175424252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424252">(Sep 11 2019 at 12:08)</a>:</h4>
<p>ah</p>



<a name="175424268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424268">(Sep 11 2019 at 12:08)</a>:</h4>
<p>local vars</p>



<a name="175424295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424295">(Sep 11 2019 at 12:08)</a>:</h4>
<p>nevermind</p>



<a name="175424304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424304">(Sep 11 2019 at 12:08)</a>:</h4>
<p>ok, so generators have local variables in their generated struct</p>



<a name="175424311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424311">(Sep 11 2019 at 12:08)</a>:</h4>
<p>while closures use the stack</p>



<a name="175424324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424324">(Sep 11 2019 at 12:08)</a>:</h4>
<p>this is because generators need to remember a bunch of their locals across yield points</p>



<a name="175424351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424351">(Sep 11 2019 at 12:09)</a>:</h4>
<p>so during the computation of the layout of the generator we need to know the MIR in order to know which variables we need</p>



<a name="175424375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424375">(Sep 11 2019 at 12:09)</a>:</h4>
<p>now the big question is why are we computing the layout of the generator</p>



<a name="175424495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424495">(Sep 11 2019 at 12:10)</a>:</h4>
<p>So it looks like the line that's failing (at least for the <code>src/test/ui/generator/control-flow.rs</code> test, is this:</p>
<div class="codehilite"><pre><span></span>(((*(_1.0: &amp;mut [generator@src/test/ui/generator/control-flow.rs:26:15: 30:6 {fn(std::ops::Range&lt;i32&gt;) -&gt; &lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::IntoIter {&lt;std::ops::Range&lt;i32&gt; as std::iter::IntoIterator&gt;::into_iter}, i32, std::ops::Range&lt;i32&gt;, ()}])) as variant#3).0: std::ops::Range&lt;i32&gt;) = move _2
</pre></div>



<a name="175424519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424519">(Sep 11 2019 at 12:11)</a>:</h4>
<p><span aria-label="face palm" class="emoji emoji-1f926" role="img" title="face palm">:face_palm:</span></p>



<a name="175424523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424523">(Sep 11 2019 at 12:11)</a>:</h4>
<p>ok</p>



<a name="175424550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424550">(Sep 11 2019 at 12:11)</a>:</h4>
<p>So I assume the issue has something to do with the combination of the deref and the tuple projections</p>



<a name="175424597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424597">(Sep 11 2019 at 12:12)</a>:</h4>
<p>well, it has to do with projecting into the generator from the generator's body</p>



<a name="175424598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424598">(Sep 11 2019 at 12:12)</a>:</h4>
<p>I'm guessing we didn't need the layout of the bare generator type before since the deref is nested in other projections</p>



<a name="175424611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424611">(Sep 11 2019 at 12:12)</a>:</h4>
<p>I wonder why we already have a desugared generator at this point</p>



<a name="175424849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424849">(Sep 11 2019 at 12:16)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116883">@tmandry</span> we have a small dilemma wrt running const propagation on generator MIR</p>



<a name="175424889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424889">(Sep 11 2019 at 12:17)</a>:</h4>
<p>Here's the MIR from right before const_prop runs: <a href="https://gist.github.com/wesleywiser/46759330b21aac1347641dc0322561ce" target="_blank" title="https://gist.github.com/wesleywiser/46759330b21aac1347641dc0322561ce">https://gist.github.com/wesleywiser/46759330b21aac1347641dc0322561ce</a></p>



<a name="175424999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175424999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175424999">(Sep 11 2019 at 12:18)</a>:</h4>
<p>apparently the layout of a generator depends on the MIR after optimizations, but in order to run const propagation we essentially const eval the MIR, which creates constant memory that matches the local's layout</p>



<a name="175425051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175425051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175425051">(Sep 11 2019 at 12:19)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> in the short term I suggest you just skip const prop on the MIR of generators</p>



<a name="175425108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175425108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175425108">(Sep 11 2019 at 12:20)</a>:</h4>
<p>Ok <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="175425111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175425111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175425111">(Sep 11 2019 at 12:20)</a>:</h4>
<p>leave a FIXME there, but we should definitely keep talking about it</p>



<a name="175425129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175425129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175425129">(Sep 11 2019 at 12:20)</a>:</h4>
<p>Will do</p>



<a name="175425131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175425131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175425131">(Sep 11 2019 at 12:20)</a>:</h4>
<p>Thanks!</p>



<a name="175473130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175473130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175473130">(Sep 11 2019 at 20:32)</a>:</h4>
<p>I think we could get around this by inserting an intermediate query that goes before <code>optimized_mir</code></p>



<a name="175473241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175473241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175473241">(Sep 11 2019 at 20:33)</a>:</h4>
<p>and depend on that from the layout code instead</p>



<a name="175508468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175508468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175508468">(Sep 12 2019 at 08:19)</a>:</h4>
<p>"all problems in CS can be solved by another level of indirection"</p>



<a name="175509886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175509886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175509886">(Sep 12 2019 at 08:43)</a>:</h4>
<p>we have such a query, the problem is that <code>optimized_mir</code> steals its result to reduce memory load</p>



<a name="175509902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175509902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175509902">(Sep 12 2019 at 08:43)</a>:</h4>
<p>so if anyone calls <code>optimized_mir</code>, calling <code>mir_built</code> will fail</p>



<a name="175509983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175509983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175509983">(Sep 12 2019 at 08:44)</a>:</h4>
<p>there's no way to resolve cycle errors. You can only break cycles</p>



<a name="175510115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510115">(Sep 12 2019 at 08:46)</a>:</h4>
<p>I mean we could pessimize generators by skipping const prop on places to a generator struct</p>



<a name="175510136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510136">(Sep 12 2019 at 08:47)</a>:</h4>
<p>it's probably the best case scenario anyway. If we want real const prop on generators, we need to run const prop on the MIR of the generator that still has all the generator yield things in place</p>



<a name="175510206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510206">(Sep 12 2019 at 08:48)</a>:</h4>
<p>though that may screw up const qualif or borrowck</p>



<a name="175510208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510208">(Sep 12 2019 at 08:48)</a>:</h4>
<p>aargml</p>



<a name="175510209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510209">(Sep 12 2019 at 08:48)</a>:</h4>
<p>ok</p>



<a name="175510253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510253">(Sep 12 2019 at 08:49)</a>:</h4>
<p>I wonder if we can do something similar to what <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> did for <code>promoted</code>s</p>



<a name="175510273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510273">(Sep 12 2019 at 08:49)</a>:</h4>
<p>so we get access to the generator state variant types without having to access the MIR</p>



<a name="175510277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510277">(Sep 12 2019 at 08:49)</a>:</h4>
<p>oh yea, that could work</p>



<a name="175510376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175510376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175510376">(Sep 12 2019 at 08:51)</a>:</h4>
<p>I wonder if we could optimize these generator variant types more by eliminating unneeded fields</p>



<a name="175730157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175730157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175730157">(Sep 15 2019 at 03:19)</a>:</h4>
<p>If you can, that’d be extremely nice</p>



<a name="175730209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175730209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175730209">(Sep 15 2019 at 03:20)</a>:</h4>
<p>I’m not sure what solution is being proposed at this point though :)</p>



<a name="175801609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175801609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175801609">(Sep 16 2019 at 10:55)</a>:</h4>
<p>it's twofold</p>



<a name="175801658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175801658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175801658">(Sep 16 2019 at 10:56)</a>:</h4>
<p>one fixes our cycle problem by separating the generator types from the MIR once computed</p>



<a name="175801675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175801675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175801675">(Sep 16 2019 at 10:56)</a>:</h4>
<p>the other part is to optimize generator MIR before doing the state machine generation</p>



<a name="175890268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890268">(Sep 17 2019 at 09:39)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>  So based on the review feedback, I should add hooks for:</p>
<p>1. Accesing a local?<br>
2. Accessing <code>static</code>s<br>
and then create and impl a machine for ConstProp?</p>



<a name="175890276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890276">(Sep 17 2019 at 09:39)</a>:</h4>
<p>we already have a hook for accessing statics I think</p>



<a name="175890333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890333">(Sep 17 2019 at 09:40)</a>:</h4>
<p>ah no, that's just for foreign statics</p>



<a name="175890341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890341">(Sep 17 2019 at 09:40)</a>:</h4>
<p>so yea, a new hook would be good</p>



<a name="175890350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890350">(Sep 17 2019 at 09:40)</a>:</h4>
<p>Ok</p>



<a name="175890357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890357">(Sep 17 2019 at 09:40)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="175890390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890390">(Sep 17 2019 at 09:41)</a>:</h4>
<p>this is also great because we can just override <code>enforce_validity</code> instead of reimplementing the checks ourselves</p>



<a name="175890446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890446">(Sep 17 2019 at 09:42)</a>:</h4>
<p>Oh, for that bit of code left in <code>const_prop()</code> before we call <code>eval_rvalue_into_place()</code>?</p>



<a name="175890469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890469">(Sep 17 2019 at 09:42)</a>:</h4>
<p>hehe yes</p>



<a name="175890510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890510">(Sep 17 2019 at 09:43)</a>:</h4>
<p>Yeah, that's great</p>



<a name="175890518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890518">(Sep 17 2019 at 09:43)</a>:</h4>
<p>oh and you may be able to nix some of the special binary op handling by implementing the binary op hook</p>



<a name="175890541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890541">(Sep 17 2019 at 09:43)</a>:</h4>
<p>all the function, frame and function hooks can just error for now I guess</p>



<a name="175890543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890543">(Sep 17 2019 at 09:43)</a>:</h4>
<p>I'll look into that</p>



<a name="175890586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890586">(Sep 17 2019 at 09:44)</a>:</h4>
<p>What did you think of this? <a href="https://github.com/rust-lang/rust/pull/64419#discussion_r325008824" target="_blank" title="https://github.com/rust-lang/rust/pull/64419#discussion_r325008824">https://github.com/rust-lang/rust/pull/64419#discussion_r325008824</a></p>



<a name="175890587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890587">(Sep 17 2019 at 09:44)</a>:</h4>
<p>not necessary for the same PR wrt binary op</p>



<a name="175890605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890605">(Sep 17 2019 at 09:44)</a>:</h4>
<p>I don't see any reason to restrict access to non-mutating statics</p>



<a name="175890611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175890611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175890611">(Sep 17 2019 at 09:44)</a>:</h4>
<p>I could be missing something though</p>



<a name="175891007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175891007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175891007">(Sep 17 2019 at 09:51)</a>:</h4>
<p>I don't see any reason either</p>



<a name="175892604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175892604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175892604">(Sep 17 2019 at 10:19)</a>:</h4>
<p>If we create a <code>ConstPropMachine</code>, doesn't that mean we won't be able to share <code>const_eval</code> results with the rest of rustc since we'll need to evaluate constants with our machine to get the correct checking?</p>



<a name="175893359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175893359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175893359">(Sep 17 2019 at 10:33)</a>:</h4>
<p>Actually, I think this will work out the same as it does currently.</p>



<a name="175898562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175898562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175898562">(Sep 17 2019 at 11:58)</a>:</h4>
<p>yea, the <code>const_eval</code> query still invokes the regular machine</p>



<a name="175904400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175904400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175904400">(Sep 17 2019 at 13:14)</a>:</h4>
<p>Is there a good way to reuse most of the existing <code>CompileTimeInterpreter</code> machine implementation? I thought maybe I could just compose a new <code>Machine</code> on top of it, do the validation we're interested in, and then dispatch to the underlying <code>CompileTimeInterpreter</code> but the <code>InterpCx</code> is what calls into the <code>Machine</code> so I don't think that will work.</p>



<a name="175904472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175904472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175904472">(Sep 17 2019 at 13:15)</a>:</h4>
<p>yea that won't work. What logic do you want to re-use?</p>



<a name="175904484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175904484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175904484">(Sep 17 2019 at 13:15)</a>:</h4>
<p>I mean what you can always do is move the impl into a free function with the appropriate generics and call that</p>



<a name="175904886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175904886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175904886">(Sep 17 2019 at 13:20)</a>:</h4>
<p>I thought I'd want pretty much all of the implementation but maybe that's the wrong assumption</p>
<p><a href="https://github.com/rust-lang/rust/blob/a44881d892fb4f4a8ed93f8f392bab942fac7a41/src/librustc_mir/const_eval.rs#L302-L479" target="_blank" title="https://github.com/rust-lang/rust/blob/a44881d892fb4f4a8ed93f8f392bab942fac7a41/src/librustc_mir/const_eval.rs#L302-L479">https://github.com/rust-lang/rust/blob/a44881d892fb4f4a8ed93f8f392bab942fac7a41/src/librustc_mir/const_eval.rs#L302-L479</a></p>



<a name="175905255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175905255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175905255">(Sep 17 2019 at 13:24)</a>:</h4>
<p>I mean we don't have function calls yet, so all the stack pushing and function resolution stuff can be stubbed out</p>



<a name="175905271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175905271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175905271">(Sep 17 2019 at 13:24)</a>:</h4>
<p>a bunch of stuff is stubbed out in const eval and can just be duplicated or moved onto the trait</p>



<a name="175905583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175905583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175905583">(Sep 17 2019 at 13:28)</a>:</h4>
<p>Ah, ok. I won't worry about de-duplicating anything then until I have it actually working.</p>



<a name="175905601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175905601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175905601">(Sep 17 2019 at 13:28)</a>:</h4>
<p>yea, the stubs are super tiny</p>



<a name="175963849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175963849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175963849">(Sep 18 2019 at 01:30)</a>:</h4>
<p>This might be a dumb question, but do we <em>really</em> need a <code>ConstPropMachine</code>? Couldn't we just add those hooks and put the appropriate implementations in the existing <code>CompileTimeInterpreter</code> <code>Machine</code>?</p>



<a name="175978154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175978154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175978154">(Sep 18 2019 at 07:31)</a>:</h4>
<p>Some things are dead code in const eval and only reachable from const prop</p>



<a name="175978193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Using%20%60InterpCx%60%20more/near/175978193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Using.20.60InterpCx.60.20more.html#175978193">(Sep 18 2019 at 07:31)</a>:</h4>
<p>I feel like it makes sense to keep them separate, since having some things be ICEs in const eval and errors in const prop will help us catch bugs</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>